Serial Communication Sync Problem
Borgel
Posts: 23
Hey all,
I have been messing around with a BS2 and a CMU Cam 2+ (essentially the same as the CMU Cam 2) for a little while now, but have run into a serial problem.
The two seem to be able to talk to eachother (I can make the user and track LEDs turn on and off), but whenever I try to track a color or get the mean color data from the camera, I get erratic, rnadom data. I am immediatly storing the packet data in an array, and I think it is slowing the BS2 down so it misses part of the incoming data. If this is infact the problem, it explains the faulty data.
The solution I am going to try is to add additional wait time between bits in the stream when the CMU Cam sends its data. In addition, I am using the slowest baud rate they both support (1200) to try and make it sync correctly. The CMU Cam 2 does not support any sort of flow controll.
The camera has been tested with a PC and HyperTerm (and the Java GUI) and it does work correctly both in general and at this baud rate.
My question is: Does anyone have a possible solution to solve the timing problem? Will my solution work? If so, how much wait time should I add (it can be incremented form 0-255 in increments of time equal to the amount of time it takes to send 1 bit)?
Borgel
I have been messing around with a BS2 and a CMU Cam 2+ (essentially the same as the CMU Cam 2) for a little while now, but have run into a serial problem.
The two seem to be able to talk to eachother (I can make the user and track LEDs turn on and off), but whenever I try to track a color or get the mean color data from the camera, I get erratic, rnadom data. I am immediatly storing the packet data in an array, and I think it is slowing the BS2 down so it misses part of the incoming data. If this is infact the problem, it explains the faulty data.
The solution I am going to try is to add additional wait time between bits in the stream when the CMU Cam sends its data. In addition, I am using the slowest baud rate they both support (1200) to try and make it sync correctly. The CMU Cam 2 does not support any sort of flow controll.
The camera has been tested with a PC and HyperTerm (and the Java GUI) and it does work correctly both in general and at this baud rate.
My question is: Does anyone have a possible solution to solve the timing problem? Will my solution work? If so, how much wait time should I add (it can be incremented form 0-255 in increments of time equal to the amount of time it takes to send 1 bit)?
Borgel
Comments
Since it is a Parallax product, you can always directly email support@parallax.com for direct assistance.
Below is my more general impression of such serial problems.
How about hardware control?
Software control [noparse][[/noparse]such as X0n and XOff ]is somewhat unreliable when used alone because if you miss one XOff, the whole scheme is out of whack.
Waiting may not really work -or- it may work fine.· So this is an alternative.
It may be that your PC and HyperTerm (and the Java GUI) are all using the hardware handshaking.
The 'dedicate RS-232' is somewhat limited as it really has only Tx and Rx.
You may need to adjust from that 'dedicated RS-232' port to 4 other pins and use a MAX232 to bring the RS-232 interface to the BS2.
Jon recently posted a mention of a Nuts&Volts article on the subject. While a have a copy of it here somewhere, I cannot easily dig it out of allthe papers. You might glance as the last two pages of threads for similar topics as it was within a week. Or just use SEARCH on RS-232.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Post Edited (Kramer) : 11/19/2005 10:58:02 AM GMT
·· Just my two cents worth, Try a BS2 px· it is the latest BS2··
·· and is WAY faster than the BS2 and has a few more goodies in it.
·· BS-2 BS-2-40pin· BS-2 p BS-2 pe and the px
·· Cheers Dennis
It appears that the CMU that you have is NOT completely compatible with the BasicStamps because of a very fast serial data rate.· Maybe the BS-2px will work, but you really need to get some direct support from Parallax to do so rather than deal with speculation from us well-wishers.
It may also work with the Java Stamp and not the regular one.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
I own an original CMUcam (not the parallax version) that I have used with an ordinary BS2 communicating at 9600 baud and I can't recall ever missing a datapacket unless I had a wiring problem, something was unplugged, I had low batteries, forgot to pull My RS232 chip out of the board, or some other problem not related the actual comunication protocol. I have also used a borrowed CMUcam2, with identical results.The 2+ can't be much different.
A couple of things to check-
set your CMUcam so it only sends one data packet per request. the CMUcam sends so many datapackets so fast that the Stamp won't keep track of them, and the Stamp won't be able to ask for different packets as easily because by the time the Stamp figures out you are between packets, the camera is sending another one.·Its not the comunications speed, its the relative speeds of the processors that is the issue.
Also,check for ground loops or bad grounds. Are you connecting the battery ground and the data ground together at the camera or at the processor? is the CPU ground connected to the camera ground? is it at more than one location that they are connected?·If the camera LED is glowing (look in a dark room) even if·you turn ·camera on-off switch· off but the BS2 board is on, you probably have a problem. I find it best to use a "star" grounding system on my robots- all grounds connected at one point.
Hope his helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔