Hello,
I am designing a circuit based around the Picaxe 40X2 and am running into a bit of trouble processing the serial data.
My application will require a lot of back and forth serial communication. For now, I'm using the programming serial interface, but planning to switch to the hardware port for background receive in the future.
The board is powered from a computer ATX PS which has a nice, smooth 5.02 V output. There is a 100uF capacitor ,followed by a 100nf closer to picaxe (decoupling) to help things along. The reset pin is tied high via a 4k7 resistor (though , in my experience, leaving it floating was never an issue). There is a 16Mhz crystal linked on the resonator pins and grounded by means of two 22pf capacitors. Apparently, resonators have gone extinct where I live
I'm using the AXE027 cable without any alterations and the 22k , 10k download circuit as described in the manual.
Basically, the software is a serial loop-back with only a handful of code lines. It a nutshell it looks something like this:
Setfreq em64
pause 500
disconnect
main:
serrxd b1,b2,b3
if b1=97 then gosub ssave
sertxd (b1,b2,b3)
goto main
ssave:
reconnect
goto save
On the computer side of things, I've written a short program in VB.NET that generates 3 random bytes, making sure the first one is not 97, then sends them over the serial port at 76800 bps. byte 97 is my escape byte, so I don't have to hardware reset the picaxe for downloading a new program. It then loops until the receive buffer has received 3 bytes and compares them to what has been sent. If they are the same it increments HIT , otherwise it increments MISS.
The hit and miss counters basically act as loop-back success or error counters.
My problem: Sometimes I count hundreds of hits without any miss and other I barely get to 100.
So far, I've tried the following:
-replace crystal with 8Mhz crystal + readjust serials speeds = NOK
-Used internal resonator (setfreq m8)+ readjust serials speeds = NOK
-Use fresh 3 x AA batteries as power supply = NOK
-Tried Calibreq ...over the whole range = NOK
-Tried putting a pause in between receive and send. Pause 5 -> 50 . Except for getting slower = NOK
By Not OK, I mean same erratic behavior. At times, one serial error in hundreds, while other bundles of errors.
The cable itself is fine, I believe. I'm using the same one to program my scrolling LED display, which also sends tons of data and works fine.
The finished prototype should work something of the sorts: get some serial data, CRC Check, PINSX = serial data , read some ADCs and send them back to the host + acknowledge CRC OK - or CRC Fail and resent from gcode line number(hint, wink,wink). Should any schematics, source code ,etc be required, I will gladly upload as soon as I get home.
If this type of behavior considered normal over fast serial communication or am I missing something here ? I was planning on going full throttle on the baudrate, but meanwhile I'm hung on this
Any help from the community is much appreciated.
Cheers,
Claudiu
I am designing a circuit based around the Picaxe 40X2 and am running into a bit of trouble processing the serial data.
My application will require a lot of back and forth serial communication. For now, I'm using the programming serial interface, but planning to switch to the hardware port for background receive in the future.
The board is powered from a computer ATX PS which has a nice, smooth 5.02 V output. There is a 100uF capacitor ,followed by a 100nf closer to picaxe (decoupling) to help things along. The reset pin is tied high via a 4k7 resistor (though , in my experience, leaving it floating was never an issue). There is a 16Mhz crystal linked on the resonator pins and grounded by means of two 22pf capacitors. Apparently, resonators have gone extinct where I live
I'm using the AXE027 cable without any alterations and the 22k , 10k download circuit as described in the manual.
Basically, the software is a serial loop-back with only a handful of code lines. It a nutshell it looks something like this:
Setfreq em64
pause 500
disconnect
main:
serrxd b1,b2,b3
if b1=97 then gosub ssave
sertxd (b1,b2,b3)
goto main
ssave:
reconnect
goto save
On the computer side of things, I've written a short program in VB.NET that generates 3 random bytes, making sure the first one is not 97, then sends them over the serial port at 76800 bps. byte 97 is my escape byte, so I don't have to hardware reset the picaxe for downloading a new program. It then loops until the receive buffer has received 3 bytes and compares them to what has been sent. If they are the same it increments HIT , otherwise it increments MISS.
The hit and miss counters basically act as loop-back success or error counters.
My problem: Sometimes I count hundreds of hits without any miss and other I barely get to 100.
So far, I've tried the following:
-replace crystal with 8Mhz crystal + readjust serials speeds = NOK
-Used internal resonator (setfreq m8)+ readjust serials speeds = NOK
-Use fresh 3 x AA batteries as power supply = NOK
-Tried Calibreq ...over the whole range = NOK
-Tried putting a pause in between receive and send. Pause 5 -> 50 . Except for getting slower = NOK
By Not OK, I mean same erratic behavior. At times, one serial error in hundreds, while other bundles of errors.
The cable itself is fine, I believe. I'm using the same one to program my scrolling LED display, which also sends tons of data and works fine.
The finished prototype should work something of the sorts: get some serial data, CRC Check, PINSX = serial data , read some ADCs and send them back to the host + acknowledge CRC OK - or CRC Fail and resent from gcode line number(hint, wink,wink). Should any schematics, source code ,etc be required, I will gladly upload as soon as I get home.
If this type of behavior considered normal over fast serial communication or am I missing something here ? I was planning on going full throttle on the baudrate, but meanwhile I'm hung on this
Any help from the community is much appreciated.
Cheers,
Claudiu