Shop OBEX P1 Docs P2 Docs Learn Events
BS2P Newbie - Page 2 — Parallax Forums

BS2P Newbie

2»

Comments

  • willembadwillembad Posts: 47
    edited 2012-05-18 13:05
    msh5686 wrote: »
    Sorry, Zoot. Thought I had attached this earlier. The sensor I have no documentation for (no issue with this part, just supplies a voltage depending on oxygen content), but the data logger is the parallax memory stick data logger #27937. Anyway, here is the program. Slot 2 is the real issue with regards to the data logging write portion.

    Mike

    Just noticed this in this thread. Are you building an automated nitrox stick by any chance? I'm in the process of doing this and I'm using a Teledyne R17 sensor. I'm having no luck amplifying the signal to be able to convert it to digital. If you have that part down I'd like to see your schematic if possible to share of course. I have a whole thread here http://forums.parallax.com/showthread.php?139803-Help-needed-with-mV-input-BS2-project


  • davejamesdavejames Posts: 4,047
    edited 2012-05-18 13:13
    Willem - isn't wild to find similar projects on this site?

    I'm always amazed at what people are doing with microcontrollers and such.
  • msh5686msh5686 Posts: 70
    edited 2012-05-21 07:53
    Willembad,

    No I'm doing something a little different. But I did have troubles with the signal amplifying myself. What it came down to was the current put out by the O2 sensor was extremely low and the op amp I was using wouldn't work that low. I switched to using something like the OPA4227 which did the job. The only complaint I have with this op amp is it is dual supply which I don't like.
  • ZootZoot Posts: 2,227
    edited 2012-05-21 09:36
    Mike -- sorry, I finally had a chance to look at this.

    I see a number of things in your code that *may* work, but are either confusing or unnecessary. That said, if the program is more or less working as you'd expect (and as you'd like), those issue are a bit off-topic (but see example below).

    The immediate problem is in how you choose to address SPRAM when writing your 5 byte buffer reads to the data logger. I think you mistook my example of a 10 byte buffer for working code. Since it appears that you only have 4 words you want to write, you don't need much of a buffer (at least by my reading).

    That said, I'm totally confused about what bytes you are wanting to log. In the slot 2 program, where you write to the datalogger, it *appears* that you are reading serial bytes from --- where?? exactly? And then populating your buffer variables and writing them out.

    But slot 1 *appears* to populate some SPRAM addresses with actual read data... so I would *think* that your data writing routine would want to read those SPRAM values and write to the logger? Do I have that right? If that's the case, cleaning up the read/write code in slot 2 would probably take care of it (I started to do this for you, but realized I was unclear on what exactly you wanted to read/write).

    Now, that said, I'm still a bit muddled about some other aspects of the application, but that might not be relevant to your immediate needs. For example, in slot 1, you have DO:LOOP that runs through reading the sensors 10 times, but you also increment a counter and then check to see if it's >= 10 AFTER the DO:LOOP. Then you choose to RUN slot 2 if it is >= 10. This strikes me as superfluous -- the loop will always run 10x, then you could just have the code to write when it's done. Your code will never execute the code after the loop UNTIL it's cycled 10x, so the check for a count of 10 is for ... what? Again, I may be missing something here.

    Lastly, the demo code I saw for this product -- http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/datalogger/List/0/SortField/4/ProductID/434/Default.aspx -- does not exactly sync up to what I see in your code. Is that the logger you are using? I am not terribly familiar with this specific product, so I may not be able to speak to specifics of utilizing some of the file and filesystem commands for that device.
  • msh5686msh5686 Posts: 70
    edited 2012-05-21 13:13
    Hey Zoot,

    Thanks for getting back to me. I did change the code to writing out only 4 bytes. Those 4 bytes I want to write are the four stored in EEPROM and loaded back into the variables. Before, I was trying to use only one variable word to continuously call data from the SPRAM and put it in that variable to send out so I wouldn't have to take up so much space with all those words. Either way, it works now with the smaller buffer. I am using the data logger you found on the Parallax site. The do loop counter and the if:then statement was a superfluous mistake, thank you for pointing that out to me.
  • ZootZoot Posts: 2,227
    edited 2012-05-21 14:22
    OK, so you want to use just one word (how about just one byte) to send the four Words from SPRAM? That would look like this:
    ' the only thing I'm not sure of is if you need separators or something between each byte
    
    ' --> here is where you should open file for writing
    
      FOR i = 0 TO 7  ' read and write 4 WORD values (8 bytes) from SPRAM 0 ... 7 (0,2,4,6 as words)
        GET i, buffer  ' single byte buffer
        IF i.BIT0 = 0 THEN ' only "start" the word in the file if it's the first byte of the word
         ' not sure about leading bytes here before each byte of data
           SEROUT TX\CTS, Baud, ["WRF", $00, $00, $00, $14, CR, buffer]  ' start the word in the file
        ELSE
           SEROUT TX\CTS, Baud, ["WRF", buffer] 
        ENDIF
      NEXT
    
    '-> here is where you should close the file
    
    
  • msh5686msh5686 Posts: 70
    edited 2012-05-22 08:08
    Whoa I didn't even know I could do that. Thanks a ton Zoot! I'm going to get playing with this and will let you know how it goes.
  • willembadwillembad Posts: 47
    edited 2012-05-23 15:08
    msh5686 wrote: »
    Willembad,

    No I'm doing something a little different. But I did have troubles with the signal amplifying myself. What it came down to was the current put out by the O2 sensor was extremely low and the op amp I was using wouldn't work that low. I switched to using something like the OPA4227 which did the job. The only complaint I have with this op amp is it is dual supply which I don't like.

    I would be so grateful if you could share your schematic. Also would like to know the specs or at least the model of your sensor. I'm coming up short so far on my end.
  • msh5686msh5686 Posts: 70
    edited 2012-05-24 06:15
    Well believe it or not, but I got my oxygen sensor from a Jeep Liberty in a junkyard. I will get back to you on the schematic, I don't have one made at the moment.
  • msh5686msh5686 Posts: 70
    edited 2012-05-24 06:32
    Willem,

    Here is the schematic I put together. I was in a bit of a rush, but don't think I missed anything. Let me know if you see anything wrong with it.

    Schematic.jpg
    1024 x 690 - 60K
  • willembadwillembad Posts: 47
    edited 2012-05-25 05:30
    Thank you. I'll play around with that and see if it works. I think the automotive sensors have higher voltage output. Do you have to heat the sensor? I was under the impression that they didn't work well if not at or near normal exhaust gas temperatures?
  • msh5686msh5686 Posts: 70
    edited 2012-05-25 06:51
    The voltage output I am reading from the sensor in the mV range so I don't think its much higher. I believe they do need to be at temperature, but this isn't an issue for me because my project is working with exhaust anyway so I lucked out.
Sign In or Register to comment.