Not sure if this belongs in ARC-32. If not, let me know. :slight_smile:
I am used to using serial uarts but this is something new to me. Single wire serial open drain?? How do I connect this device to the arc-32? I am guessing to one of the I/O pins and set the pin to an output, send the serial data, then change the pin to an input and read the serial data? All I want to do is read the color of an object that is in contact with the sensor. Here is the data sheet: [parallax.com/Portals/0/Downloads/docs/prod/sens/28380ColorPAL.pdf](http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/28380ColorPAL.pdf)
Basic Stamp I/O and code is similar to ARC-32. Use one of the I/O pins (like their pin 15), download the software and adjust for BasicMicro. Follow their instructions.
Come back and give status reports and ask questions!
Also you don’t have to set it to an output. the serout command will do that. Also the serin will turn the pin specified back into an input as well when it is used.
Ok, I converted the code and am having some issues. If I use serin/serout on pin 2 I can reset the color sensor by sending the pin low for 50ms as shown in the reset subroutine from the data manual. but can not get it to receive or transmit serial data. If I use the hserout2/hserin2 I can send the sensor data but cannot receive data back or reset the sensor by taking the pin low.
Ok this dosnt work:
serout P2, neo4800 “=R!”] 'no spaces in direct mode
This does work on the aux 1 header:
enablehserial2
sethserial2 h4800,h8databits,hnoparity,h1stopbits
hserout2 “=R!”]
I have been all over the net and have done a lot of reading. Is this due to no buffer on regular serial? Am I missing something? I am a relative noob so probably.
Options?
Use the aux1 header with hardware serial and put a diode between the tx and rx pins?
Get a i2c to hserial converter to save my needed aux1 hserial?
Sometimes I find what some processors consider to be inverted is different than others consider inverted. So the first thing I would try is:
serout, p2, ieo4800,…
Also I would try dropping the “e” as I did not see anywhere in the documentation that it said it wanted even parity. Could be wrong. So I would try: NO4800 and IO4800 and see if any of them work.
Nice suggestion! But no go. I tried both along with all the combinations at 2400 baud as well. There isnt an adjustment for baud on the arc 32 is there? I havent seen anything about it.
Have you tried dropping the open drain (o) from the baud mode? I don’t think the hserout would be acting in open drain mode. Could be wrong. If this sort-of works than Nathan(AcidTech) probably needs to take a look.
The full code is now working! Thanks for the help guys. Here is the code:
'----- set up variables ] -------------------------
red var word
grn var word
blu var word
'----- enable hardware serial for terminal view ] —
enablehserial
sethserial h9600,h8databits,hnoparity,h1stopbits
'----- intialization ] ----------------------------
gosub Reset
'----- program code ] ----------------------------
serout P2, i4800, “=(00 $ m)!”]
Note that if you WANT to use opendrain serial mode you need to have a BUS pullup on the serial line. A 1k or a 10k(if a slow baud rate) should sufice.
For those that don’t know, an open drain signal only drives LOW. A high on an open drain signal is just floating. If there is no external pullup on the signal line the signal wil most likely remain low and you’ll get NO signal.
Were you planning on running multiple devices from the same serial pins? If not it doesn’t matter whether you use open drain or not, but if you want or need to use it as a bus then open drain will be necessary in the long run.
No, I wasnt going to use multiple devices on the same pin. It works perfect for what I need. I just thought it was strange that the spec sheet for the Colorpal said it was open drain with internal pullup. But as alan stated it might just be a weak pullup. I see one smt resistor outside the colorpal shell/housing that is in series with the signal pin and it has the number 331 which is I think 330ohms.
Pullup resistors are never in-series. What you are seeing is a current limiting resistor. Its a safety feature on many I/O pins. Also pullups will almost always be 1k or larger. Current limiting resistors are using in 100 to 300ohm range.