---
+ Post New Thread
Results 1 to 19 of 19
  1. #1
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    PIC 16F684 Data Logger Design

    Hi there,

    I'm working on a design for a data logger that can record the ambient temperature and buried temperature for a University Project that I am involved with. Due to financial restraints that the University has placed on us I have no option but to design it from scratch.

    I have ordered a number of different temperature sensors from the LM35 to K type thermocouples, most are off good old Ebay and should arrive in about 10 days time...

    One of the problems that I currently have is getting the basic code up and running as I just cannot remember how to program in C as it's been 5 years since I last wrote any C code, the code that I have already written did used to work with the 16F684 but no longer appears to work...

    I already have a basic design laid out, etched and populated for test purposes...

    The design does not take into account that the whole system needs to run off a 9V PP3 battery for a period of 10 weeks or longer, and needs to record the two temperatures simultaneously probably every 10 minutes to accuratly determine what is happening below and above ground at any point in time in the 10 week window...

    At the moment I am unsure how to work out what type of storage device is suitable for the project, initially I had planned on bit bashing out the data from an EEPROM but I also feel that perhaps using a SD Card could also work...

    I'm attaching the source code that I have currently written, even though it does not work and the schematic drawing for the test board that I am using, currently the board is being programmed using ICSP...

    I require some assistance getting the design up and running as quickly as possible as I only have untill the end of July as the Third Year project kicks off in August...

    *** JUST REMOVED ATTACHMENT AS CODE IS INCORRECT ***

  2. #2
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    Re: PIC 16F684 Data Logger Design

    The schematic you have uploaded is for connecting a joy stick by the looks of it and does not contain the SD card unless you have this on another board. Also it has no LCD or the R network.

    Sorry I do not do C, There are a couple of ways you can carry this out.
    Like you say either eeprom or SD card way will work. I have used both ways, the Eeprom way I added an RS232 to up load into Excel and the other way I uploaded through an hyper terminal then saved has a text file then used a little utility to open it and put it onto a graph then exported to Excel. Has for the SD card way I created a CSV file which excel can open. But I can create a TXT file and use the same utility to view the graph.
    I think you may be asking a bit much to run it of a 9v battery for 10 weeks 24/7, It may be possible if you useEEprom/ SD card and turn it off in between the 10minutes and put the pic to sleep and wake up every 10 minutes take sample then fall back to sleep. Sorry this may have not been much help but I don’t use C otherwise I may have been more of an help.
    I know I said you have no LCD or SD board and you may not need an LCD because it will be set up and you have no need to alter the sample rate ?
    It would a better data logger if you added and RTC to stamp your data with time and date or is this not what your after.
    I see you go to Wolvo uni ? not far from my own town. :D



  3. #3
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Sorry, I never said that it did contain the SD card drawing as I do not know what is required... As you can see the board was layed out in 2005 so not recent, however I am in the process of altering the schematic drawing to save on this confusion but NI have altered there software somewhat and my version of software keeps trying to upgrade to a newer version so i'm having to fight it...

    Also what's this about LCD or R Network, I'm sorry but I beleive you have this project mixed up with someone else's...

    I have no need of an LCD as this whole unit is going to be left in a field getting rained and possibly snowed on, it also will be exposed to frosts and freezing temperatures...

    Also I have not shown the Temperature Sensor as I am unsure about what type to use, as stated I have a large number of different types on order to see what works the best...

    Once I download the data via hyperterminal, it will be as a capture file in CSV format that can easily be imported into excel...

    I've never used an RTC but it does interest me as I would love to have the data and time included as that would save me a lot of hassle post processing the data...

    The University only has a license for Compton Park Campus, but as they are having to mothball this campus due to lack of funds, the unit needs to be standalone as I am unable to gain access to the site on a regular basis...

    So it needs to work off a 9v battery, so perhaps I might be forced into hourly recordings less accurate but better than daily max/min values from there weather station that might hopefully still be manned...

    If I went the SD route, how would I connect it in hardware and communicate with it in software?

    What is the best method?

    You also have me curious as to where you live? as i'm not from Wolverhampton but close enough to study there...



  4. #4
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    Re: PIC 16F684 Data Logger Design

    Right Now I understand what you want to do. If it will be out in the cold then I think SD is not the best way, Has I've not fully looked into the Sd card data sheet to see what temp they work in. eeprom may be best but would have to look into it.

    http://www.maplin.co.uk/Module.aspx?ModuleNo=10449
    This battery may be better and last longer.

    I will have a look at some data sheets and work out the current draw is with everything running, Really to be honest you have not left much time to complete this project and fully test this.
    The only reason I say this is because it is quite easy to get caught out. Your design requirements are quite simple and easy to design, Once you have decided the way you want to go and which sensor works the best for you, Then the design and code would only take a couple of days or so to do(May be not 100% bug free). Then you would have to leave it running for a few days, Then upload data to make sure all there and correct. Ideally you would want to carry out a week or two to test the logger. The ideal test would be in your garden in the real world has I would call it(in the rain, Frost and Snow for ten weeks or more). I did read somewhere that someone designed a logger, Not sure how much testing they carried out on the logger(I think his was SD card). But all was working and it was sent out in the field to do its job for 12months I believe but after 6 months they wanted to recover the data but found when they connected it to the SD card reader it only recorded the first months’ worth of data this was due to a glitch in the software. 5 months wasted,( good job they did not wait until 12months went by.)
    I don’t want to put the dampers on your project but just be careful. Opps! Getting side tracked right where we.


    I've never used an RTC but it does interest me as I would love to have the data and time included as that would save me a lot of hassle post processing the data...
    This is quite easy to add.
    So it needs to work off a 9v battery, so perhaps I might be forced into hourly recordings less accurate but better than daily max/min values from there weather station that might hopefully still be manned...
    Has said above depends on current draw , Save power by sleep and turn off epprom/sd card when not needed)
    If I went the SD route, how would I connect it in hardware and communicate with it in software?
    The SD caard requires 4 pins to communicate with it, Not sure how you would do it in C, I use PDS(Proton Development sutie)
    What is the best method?
    I would say EEprom now you said about the conditions it will be in.
    You also have me curious as to where you live? as i'm not from Wolverhampton but close enough to study there...
    I wold be he same, If your area is correct in the PDF file I know it well worked there enough times :D it could be either one of the two :D:D



    •   Alt15th June 2010, 23:41

      advertising

        
       

  5. #5
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Oh yes it's correct, forgot that was there... lol

    Just had the K type thermocouples and the DS18B20 Thermal Probe arrive...

    I realise i'm tight for time but various factors have meant that i'm limited timewise hence the reason why I am now slightly panicking and asking for help from the electronics community...

    I also feel the EEPROM is the safest option to take, however the SD Card option does mean that I do not require any serial routines, but which is the more robust method?

    Thanks for your comments so far, any further thoughts or suggestions are greatly appreciated...

    *** JUST ADDED THE SCHEMATIC BEING REFERENCED TO... ***



  6. #6
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Just got the whole board transmitting... Yipee...

    Not sure of the board rate, so I need to tweak things a tad...

    But attached is the PDF to one of the Temperature Sensors that I have been recommended to try...

    Also attached is what I am seeing on the Scope and in Hyperterminal...

    Can anyone help me translate it?

    Should be: -
    1 start bit
    12 Data Bit's
    1 Stop Bit

    But i'm not sure...



  7. #7
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    Re: PIC 16F684 Data Logger Design

    I've just had a quick thougt looking at your schematic you have no RS232 chip to transmit to the PC. Has if I remember you can't jsut do it direct from the PIC, But I never tired it I've always used an RS232.



  8. #8
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    You don't need a MAX232 when doing it like this...

    I'm actually bit bashing the data out, done it quite a few times...

    But there just seems too much data for a ">" so the other letter must be there...

    I should be recieving ">A" when a "J" is pressed...

    *** here is some info on the subject ***
    http://en.wikipedia.org/wiki/Bit-banging



  9. #9
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    Re: PIC 16F684 Data Logger Design

    Hawk has your sensors turned up. Which type sould you use ?
    Does you PIC have to be a 648 ?
    What type of memory storage will you use ?
    Did you get your serial data working.

    Wizpic



    •   Alt19th June 2010, 07:40

      advertising

        
       

  10. #10
    Full Member level 3
    Points: 3,127, Level: 13
    Enlightenment's Avatar
    Join Date
    Jul 2006
    Location
    3rd Rock From Sun
    Posts
    173
    Helped
    29 / 29
    Points
    3,127
    Level
    13

    PIC 16F684 Data Logger Design

    You don't specify the number of bytes per sample. Would 128K bytes be enough?

    Serial MRAM, 128Kx8, SPI bus:
    http://www.everspin.com/PDF/EST_MR25H10_prod.pdf

    Benefits of MRAM:
    - No battery backup required.
    - Writes extremely fast compared to FLASH and EEPROM.
    - Unlimited write. Don't have to worry about writing too many times to a memory byte of sector like other technologies.



  11. #11
    Newbie level 4
    Points: 659, Level: 5

    Join Date
    Jun 2009
    Location
    Colorado
    Posts
    5
    Helped
    0 / 0
    Points
    659
    Level
    5

    Re: PIC 16F684 Data Logger Design

    Quote Originally Posted by Enlightenment
    Very interesting part.

    Where can you buy this part ?

    I checked Digikey and Mouser, they do not carry it.

    thanks

    don



  12. #12
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Guess what daft bugger left the ICSP connected to the PicKit 1 board???

    No wonder I could not get anything to talk...

    Anyway it's now transmitting somethink...

    Just not sure what...

    I've attached what I am seeing on the Scope and in Hyperterminal...

    Can anyone help me translate it?

    I beleive it should be: -
    1 start bit
    12 Data Bit's
    1 Stop Bit
    But i'm not sure...

    Looking at the data being transmitted...

    There seems to be 30 bits of data...

    But there just seems too much data for a ">" so the other letter must be there...

    I should be recieving ">A" when a "J" is pressed...

    But I just cannot seem to get the other character to be output...

    As for the Sensors - I have now received the LM335, DS18B20 (thermal probe) and the K type temperature probe...

    I beleive the DS18B20 (thermal probe) which is pre-wired is the way to go but the code does need sorting for that...

    As for the Pic Chip, I'm using what I have to hand to save making up any circuitry as I already have boards laid out ready for experimental use (see attached image)

    Due to limited time available to me, I'm having to use what I have available to speed up the process...



  13. #13
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    In response to enlightenment...

    You don't specify the number of bytes per sample. Would 128K bytes be enough?

    Serial MRAM, 128Kx8, SPI bus:
    http://www.everspin.com/PDF/EST_MR25H10_prod.pdf

    Benefits of MRAM:
    - No battery backup required.
    - Writes extremely fast compared to FLASH and EEPROM.
    - Unlimited write. Don't have to worry about writing too many times to a memory byte of sector like other technologies.
    I just don't know... :cry:

    At the moment I am working silly hours at work and unable to concentrate on the project and when I do get time to work on it, I'm finding that sections of code that used to work, no longer work due to changes in compiler etc...

    So I feel that I am fighting a loosing battle, and need the input from the electronics community to get me back on track fast...

    Added after 3 hours 54 minutes:

    Just placed an order for this Memory Device... it's an FRAM

    I got two samples on order from
    www.ramtron.com

    The device I went for was the FM25V02 in an SOIC Package...

    Just need to work out how to communicate with it...



  14. #14
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    PIC 16F684 Data Logger Design

    I've not tried to transmit data through to RS232 striaght from the pic,Hvae you tried to TX decimel.
    I will try straight from the PIC to the PC and se how I get on, If it works then this will save a lot of time.

    Which sensor are you going for, The LM35 you will need a pic with A/D converter. the ds18b20 is one wire com.
    Sorry it is not much help at the moment but I've not add much time myself with work, It always seems to get in the way but it pays the bills :-)



  15. #15
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    I got it working...

    Turned out to be a dodgy pic chip, it was running at 9.6MHz instead of 8MHz no matter what I tried I could not get it to stabalise, so I replaced the chip and it all started to work immediatly...

    So onwards I go...

    I now have some working code, and i'm just starting to implement the DS18B20 code, but I have a problem...

    I cannot get printf to work, so therefore I can not print out any lines of text...

    Any idea how I can get round this problem?

    Also does anyone on here use proteus? Only I have forgotten how to add the power pins to a chip... only I'm using the 16F684 from the library but I just cannot locate the power pins to it... also how do I draw in new components only for years I used ulticap from Electronics Workbench prior to National Instruments taking them over and ripping me off in the process... so I have forgetten how to use it...

    I'll see it it lets me attach the various files so you can see what I am upto...

    All that's really missing is a start/stop button and the FM25V02 F-RAM memory device from RAMTRON but at the moment I just do not have a symbol that I can use for it, and the drawing options are disabled in this version of proteus...



  16. #16
    Advanced Member level 2
    Points: 10,858, Level: 25
    wizpic's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    683
    Helped
    99 / 99
    Points
    10,858
    Level
    25

    Re: PIC 16F684 Data Logger Design

    I've add a quick look at your design. The 12V and 5V you need to add a + in front of them, The way it is at the moment this will casue errors, when you transfer to ARES, I can draw components in my version which is the same has yours.

    Has for the power pins these will automaticly join to the +5V and gnd in ARES for some unknown reason they never show, Not sure myself has I don't use ISIS much but all I do know they to connect in PCB editor.

    There is an help file which explain to you how to create components which may be easier then me trying to explain.

    Keep up the good work your making good progress



  17. #17
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    PIC 16F684 Data Logger Design

    Thanks...

    My version it's greyed out...

    But if you could draw us up the FM25V02 i'd appreciate it... I went for the SOIC version to make it easy on myself whilst I prototype the board...

    As for the software I'm just playing with it, as I try and re-learn how to use it...



  18. #18
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Ok i've now got a large chunk of the code written and tested...

    But it appears that I have an issue either with the timmings or the way the code is written...

    anyone fancy having a quick look to see if they can spot my mistake?



  19. #19
    Member level 3
    Points: 1,701, Level: 9

    Join Date
    Jun 2010
    Location
    United Kingdom
    Posts
    62
    Helped
    0 / 0
    Points
    1,701
    Level
    9

    Re: PIC 16F684 Data Logger Design

    Basically I now have the unit communicating correctly and displaying a temperature value...

    But I have noticed that the first temp recorded from power up was miles out, so is the recemmended procedure to have the DS18B20 running for a couple of minutes before taking the actual temperature reading...

    Only I am planning on having the PIC sleep for an hour wake up take the measurment and then go back to sleep...

    Would I be sacrificing accuracy doing it this way...
    Only at the moment it's on the bench on a 1 metre lead from the main PCB, next to it is a cheap digital thermometer... both are held in a mini vice approximatly 6 inches off the bence away from any heat source...

    The cheap digital thermometer recorded a temperature of 23.3 degree's C

    When I powered the unit up the DS18B20 recorded the following temperatures...

    550 = 1360 x 0.0625 = 85
    16C = 364 x 0.0625 = 22.75
    16B = 363 x 0.0625 = 22.6875

    The config data is 7F so this means it's sampling at 12 bits so am I right in using 0.0625 to convert the value?

    What is the best way of getting the most accurate temperature reading with the DS18B20...



+ Post New Thread
Please login