Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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: 233
  • FLEX_LCD.c
    4.3 KB · Views: 206
  • main.c
    3 KB · Views: 218
  • onewire.c
    11.1 KB · Views: 251
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
 
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,


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

hi all i thought i would post a update on how my main project is going.... a quick recap.
the project is to fully automate comercial type incubators and although them to be indevidualy setup with different paramaters depending on A. what species there incubating and B. whether the unit is being used to incubate or hatch eggs.
For the prototypes i have set up 2 test units (1. incubator 2. hatcher). theese units physicaly look nothing like the incubator units that will be used but have the same parameters such as insulation proterties etc as the final units. the main difference is size, the test units hold approx 250-350 eggs each while the finished comercial units will hold approx 600-800 eggs each.
at present the heating is supplied by way of light bulbs (2x100W with 2x100W as backup), theese will be replaced with a heating element or cable once the tempreture control unit is complete.
the eggs are on "racks" in 5 layers, the warm air is distributed to each layer via 3 rows of 3 fans each (9 in total). currently the heating and tempreture control is being handled by a comercial 4 channel unit using DS18s20 sensors (K190unit), this unit is controlled via rs232 to a pc and software written for the K190. three of the four tempreture channels also control each row of fans (On & Off).
the main fan control is via a fan control unit wich consists of a 28 pin pic (18f2585), this unit uses software pwm to vary the speed of each individualy fan in a variable pattern (currently set by a include file). the unit works well and alows fine tuning of heating rates and humidity. future development of this unit will include linking it to humidity measurment and having the fan speed and pattern altered according to tempreture and humidity.
note. the software for the fan control unit hasnt been written by me so i will not be posting the code (sorry)

Watch Dog Unit

This unit is currently based on a 40 pin pic (18f4685) and is in prototype phase so the chip may well change, the units main functions are.

1. to monitor light output from the heating bulbs and to switch in a back up bulb when a main heating bulb fails (this happens approx 3 times over a 3 week period!), this is achieved by using a LDR on each of the bulbs, when the light level drops the unit checks the k190 heating unit to see if the heater is meant to be on or off, if it is in a off condition then no action is taken, however if the k190 returns a on condition and no light output is detected then the unit switches in a back up bulb.

2. monitors the pc status,
we have frequent small powerouts (<5mins) and sometimes the pc dosnt restart properly or dosnt restart at all wich renders the k190 useless, so the WDU monitors the pc power and parralell port if the power is on but the port isnt providing signal pulses it will restrt the pc, or if the pc is off it will restrt it.

3. the unit also monitors the power supplies for the pics and the the relays etc if any of theese supplies fail it alarms and switches in a back up.

4 the unit is also connected to a LCD wich displays each the different systems status and any fault conditions that exist.

this unit is working very well as a protype unit but is currently having a a few redesign features added and the software is undergoing a exstensive rewrite, main points regarding software for this unit is i am going to add a menu system and self test function i will also add a RTC and usart function so i can log the data via RS232 on the pc.

Humidity unit

this is the newest unit i am working on and is currently in BB prototype phase.
Like most of the units i use it has started life on a 40 pin pic (18f4685) but will eventualy be moved to eigther a 18 pin chip (18f1330) or a 28 pin chip (18f2685). for the senors i am using sensiron SHT71 sensors, theese measure bith tempreture and humidity although its mainly the humidity reading from them that i am interested in. i have yet to decide wether i will be using 1 or 3-4 sensors per incubator (or hatcher). currently i have a BB set up that monitors 1 sensor. the origanal driver i wrote was working fairly well but i have found a better driver that was written for a different compiler and have converted it to work with C18, i have also added usart so the tempreture, humidity and Dew Point are output to the pc for logging, i have also added a LCD where the tempreture and humidity are displayed, presently i am rewriting the software so it will monitor,display and log data from 3 sensors, the end aim at this point will be to have the unit adjust both humidity levels via a water resivouir systems and to alter the main fan unit speed and pattern according to layer humidity readings. it will also control dry air input fans and stale air exhaust fans via hardware pwm. i have included a photo of the early bread board version of the humdity sensor, ignore the messy board and the fact there is etc components not being used on the board, like i said it was a very early protype!!
anyway i hope you enjoyed the update! the next one will include some software as soon as i have tiedied it up a little!!​
**broken link removed**
 
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

The DS18S20 uses Maxim’s exclusive 1-Wire bus protocol that implements bus communication using
one control signal. The control line requires a weak pullup resistor since all devices are linked to the bus
via a 3-state or open-drain port (the DQ pin in the case of the DS18S20). In this bus system, the
microprocessor (the master device) identifies and addresses devices on the bus using each device’s unique
64-bit code. Because each device has a unique code, the number of devices that can be addressed on one
bus is virtually unlimited. The 1-Wire bus protocol, including detailed explanations of the commands and
“time slots,” is covered in the 1-Wire Bus System section.
 
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: 180
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
 
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: 162
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) :D :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top