Please could you help me

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
Hello, iam trying to help my dad after he lost all his stuff on the puter.
oh sorry hi its logan by the way i am trying to do our project that i was helping dad with while he is in hospital i no longer have the program.i have found another program on the internet but it isnt in mcc18 and i cant get it to work in mplab i have included the programs please could you look and tell me how to change it so it will work on 18f4685 with mcc18, also mum says thank you very much for the support for my dad. many thanks logan
ps i can do the changes if i know what to change sorry if your busy, i will be in bed soon but mum might be online
logan
 

Attachments

  • DS1820.c
    6.7 KB · Views: 238
  • FLEX_LCD.c
    4.3 KB · Views: 211
  • main.c
    3 KB · Views: 222
  • onewire.c
    11.1 KB · Views: 254
That looks suspiciously like CCS C code to me.

The main problem is that all C compilers have their own ways of doing things and some like CCS C and Mikro C provide functions to ease the pain of addressing registers etc.

What is your project? An explanation of what you ultimately want to do.

I presume that you want to use an LCD, and you want to use a 1 wire temperature sensor, did you want to just display the temperature on the LCD?

The 18F4685 is a beast of a chip! Are you making a demo board or do you have a pre-made one, if a premade one which variant, there may be some sample code that can be converted or changed to suit.

Regards

Wilksey
 
Hello wilksey thank you for the reply its my dads incubator project but i want to replace the code he lost. we use the 18f4685 and need to read upto 6 ds1820 chips. i found the normal lcd program we use but the one i posted here came with the other programs from the internet. if i can get to read tempretures from upto 6 dallas chips then my dad should be home hopefuly by then to do the rest as we dont have much time untill the markets start again, i posted here cos my dad says your all experts on chips and realyrealy good at helping people. i have done small led programs with my dad but i havnt done things this complicated i can use mplab and i can compile and put the hex in the pic i can also solder
many thanks logan
 
Hi Logan,

I dont have any DS1820 chips, nor have I personally used them in MC18.

However, I do know that each chip has a unique ROM code and browsing the datasheet I can see that you issue various commands and can add more than one device to a bus, it does say you cannot read the ROM code on each one as you will get corruption so you will need to do a seek, I presume you have the datasheet and know how to issue these commands?

I have had a quick search on the net, and without having that particular chip to test with I can only supply the link without knowing if it works or not, there is another post further down stating that the poster missed a reset sequence.
Old Nabble - PIC - [PIC] - microchip c18 - 1wire lib

Hope this helps, or at least gets you going enough to experiment with the DS1820.

There is probably someone on here who can answer your question exactly, but the link above should get you on the right track until then.

Regards

Wilksey
 


Hi,


Hope your Dad is on the mend and soon home.

The Ds1820 program code is not a beginners project at the best of times and doing it to control multiple sensors is a really big job for even a seasoned diy programmer.

I really think you will be trying to do the impossible there - you would be better searching the web to see if there are any multiple sensor examples out there that you can use and adapt.

When you say your Dad lost all the old code , some kind of hdd failure or system crash ?

Did you use one of the many free hdd recovery programs that can often pick up old data from seemingly lost files, even when the disk as been reformatted ?
 
Wp100 is correct, it is a big task to interface to one let alone many of these sensors.

Obviously we will help as much as we can, and please do take a look at the link I posted.

When you delete or format your HDD unless you performed a multiple write over will be recoverable (in most cases) because the used sectors are marked for "write" and are not actually written to. Obviously if you have already written over the data, which you wont know because the filesystem decides where it wants to write it's data to, then you wont be able to get it all back, but you may still find some files are recoverable.

Wilksey
 
Upon reading the link that Mickster has posted regarding your Dad's project, it looks as though he was interfacing a K190 Unit (4 x DS18s20 sensors) to a PC's parallel port? Or did I read that wrong?

Wilksey
 
Upon reading the link that Mickster has posted regarding your Dad's project, it looks as though he was interfacing a K190 Unit (4 x DS18s20 sensors) to a PC's parallel port? Or did I read that wrong?

Wilksey

hi,
This quote is from Jason's earlier post.
It states that a PC connected via RS232 will log the data captured by the remote PIC's

 
Thank you all very much for the reply i am off school today so can work on this. my dad dosnt use the pc units we started to use ds1820 but the computer we worked on has been damaged and he has had to buy a new pc we have units my dad made made that read a single tempreture but want to make a unit that reads 4-6 ds1820 the humidity is seperate and the program for that was on laptop not the pc so we still have that i been looking all over the internet bust cant find code for mcc18 for multiple ds1820
 
This shouldn't be to bad if you can read one you can read more . Because each device has a unique 64-bit code

 
You may or may not be open to a new idea depending on how far you've gotten the C code. Swordfish BASIC has a very good 18S20 and 1-wire library and the LCD module is dirt easy to use. Should be possible to do your incubator with the free SE version.

Is there a schematic of the project anywhere?
 
Last edited:
Update:

I have a simulation in proteus with 6 DS1822 (similar to the 1820) it will detect all 6, and it can "read" each one, i'm not sure that the simulated hardware is giving the correct codes, but I have copied code from atemel and converted it somewhat as well as using the onewire app note code from Microchip, but I cant for the life of me get the temperature to convert properly!

I can get the first 2 bytes of the scratchpad and they seem correct (50 05) for example, but I cant get the conversion routine to work for me.

If you have some working code for C18 that gets the correct temperature then the code will be working, messy, but working.

It would be easier to program in another compiler, for some reason, C18 is the most difficult one to use, even the paid version! Heh, maybe i've become lazy with all of the other compilers i've used!

Wilksey
 
Last edited:
Progress

Hi Little Ghostman.

I have (hopefully it worked) attached to this post the code I have been converting, it will now display some kind of temperature, but I dont have the hardware to test and the scratchpad codes are duplicating in proteus, and the temperatures are consistent, but consistently wrong!

It outputs to the UART at (i think) 9600BPS, no LCD at this time i'm afraid, focused on the DS18X2X sensors.

It will read up to 6 sensors, I haven't included the proteus project but I can if you wish me to, simulated on proteus using the DS1822 sensor it detected all 3 as a seperate module, has support for the 2 DS1820 modules and the DS1822 module, again not sure if the temp conversion is working properly.

Most of this code is hacked together from various sources, modified to work for the application, I have left the code comments in so you can better understand what is happening.

The bulk of the code came from a Microchip application note and an Atmel implementation of the code.

Hope this helps you, if you do get the temperature conversion working I wouldn't mind taking a look as I even copied the code from the Maxim datasheet with the generic C code, and that didn't work either! Not even taking the scratchpad first 2 values and running the algorithm on it! Strange.

Unless someone else on this forum has managed to get the temperature conversion routine working for these chips? I have tried several solutions but this was the closest.

Regards

Wilksey
 

Attachments

  • DS18X2X MC18 Code (6 Sensors).zip
    76.8 KB · Views: 184
Rachel's Comment

Thank you Wilksey for provideing the program and to everyone who is helping Logan, he isnt at school tommorow because of flooding so will be thrilled when he wakes up.
Its very kind of everyone to help him especialy when he wants to learn as much as he can and also help his dad.
Rachel xx
 

hi Rachell/Logan.

I would recommend Bill's [blueroomelectronics] suggestion [ post #12].

The free version of Swordfish basic is designed for use with the 18F series of PIC.s

Most of us have Swordfish Basic on our PC's, so we could help check your programs.

Eric
 
Thank you very much wilksey i will try and get it running in proteus first we have proteus on the laptop dad borrows from the uni where he does work i would like to do swordfish but dad only does C so he wouldnt be able to add the other bits to the program for my owm things tho i will try swordfish sounds good i am very very happy you all helping me to help my dad

thank you logan
 
i can only get the terminal in proteus to display lines or rubish i will try and make a bread board later and try and add lcd program when i get back from seeing my dad
logan
 
Proteus

Hi Logan,

With the HEX file it displays garbage in the terminal?

The display is fine on mine, with the hex file in the previous zip.

I have attached the Proteus file I created to use with the HEX, maybe that will work for you, it was created in 7.7 sp2, dont know if you have an older version if it will open.

Let me know how it goes.

Regards

Wilksey
 

Attachments

  • OneWireTSProteus.zip
    16.2 KB · Views: 167
i am still working away with wilksey's program trying to get it to work in proteus first i have been reading loads and loads on the internet and because i get something on the proteus terminal i think i have the timeing wrong in the settings but this is a guess also i read something about disableing interups when you contact the ds1820 and i noticed in the program it mentions interupts but again i am guessing it looks like its a great program that when it works will be awsome and probaly the only good mcc18 ds1820 program on the internet!! i will keep reading and reading i have tried reading the datasheet but its very complicated and i cant follow it very well
THANK YOU FOR READING
ps my dad smiled at me today (kind of)
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…