serrxd problems on 28X-1

radcom

Member
I have a 28X-1 on a project board the code running on it is as follows:
Code:
Disconnect
setfreq m8
sertxd("ok")
do

goto main

outputs:

    high 7
   if b2 = 1 then high b1 endif
   if b2 = 0 then low b1
   endif
   
main:
   serrxd b0,b1,b2
   'let pins = b0
   'let b1 = b1
   sertxd(b0,b1,b2)
   if b0 = 1 then goto outputs' else goto main endif
   
loop
the problem is when it run it in the simulator it works fine but it does not work when I compile it to the picaxe chip I am using programming editor v5.2.10 and the pic firmware on the pic is A.3 I'm sure the picaxe works

I've try putting a return after the data I send in terminal but it doesn't make a difference

the data I send is in the form of 1,2,3 and the 3rd variable seems to be missed off every time so the data sent back is 1,2

any help greatly appreciated
Radcom
 
Last edited by a moderator:

westaust55

Moderator
Since you have the PICAXE running at 8MHz,
do you have the Terminal window running at 9600 baud instead of 4800 baud to compensate?



using the code
Code:
Disconnect
 setfreq m8
pause 1000 ; to give Terminal window time to setup
sertxd("ok")
do

main:   serrxd [65000, main], b0,b1,b2

   sertxd(b0,b1,b2)
     
loop
the program accepts 3 bytes/chars and then sends them back to the terminal program.

I only have an A.2 40X1 chip and without the timeout function I get a message about A3 firmware before timeout is optional (See attached) but with A3 you should be right


Edit: Forgot to mention this is with V5.2.11 of the PE
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
Try changing the SERTXD to ...

sertxd( #b0, " ", #b1, " ", #b2, CR, LF )

As you have it the raw ASCII characters are sent to the display and some of those may be interfering with what's being displayed. Using this form you can see what decimal values the characters received have.
 

radcom

Member
Yes that was the problem I discovered it before I had chance to check my post here.
So the good news is it now fully works on windows, both with terminal in the prog editor and hyperterminal, but no matter what I try it doesn't work with my ubuntu server, which is what it is for. I have tried
Code:
echo "1,0,1#" > /dev/ttyS0"
and using python but neither works the baud rate is right and when I connect to the serial port on my server using a null modem cable to my main computer and send the command I just mentioned the data is received just fine has any one got any suggestions to offer?

the new code is
Code:
Disconnect
setfreq m8
sertxd("ok")
do

goto main

outputs:

   if b2 = 1 then high b1 endif
   if b2 = 0 then low b1
   endif
   
main:
   
   serrxd [65000, main2], #b0,#b1,#b2
main2:
   debug
   sertxd(#b0,",",#b1,",",#b2)
   if b0 = 1 then goto outputs
   

loop
BTW the data I get from debug is that it seems to copy the data in b0 into b1 and b2 which is no good but this doesn't happen when using it on windows
 
Last edited by a moderator:

westaust55

Moderator
Yes that was the problem I discovered it before I had chance to check my post here.
Thanks for letting us know that the problem is resolved, but
was "that" the
- need for adjusting terminal speed,
- adding the timeout (that is supposed to be optional for firmware at A3 and above), or
- adding a # symbol to the variable names?

Your new code has the two latter items included and not able to see if you had to change the terminal speed
 
Last edited:

radcom

Member
sorry it was the #s that sorted it and time timeout made debugging so much easier
 
Last edited by a moderator:

hippy

Ex-Staff (retired)
The problem could be with the echo ... > /dev/ttyS0 - You can install LinAXEpad on your Ubuntu box and see if you can control it using the Terminal function of LinAXEpad.

I'm a bit confused as to how you are testing this as you are using SERRXD with SERTXD and DEBUG and those will send data back to /dev/ttyS0. I would suggest rewriting your code and modifying teh hardware to use SERIN to receive data from /dev/ttyS0 and use Programming Editor under Windows or LinAXEpad under Linux to monitor what is being received by SERIN using SERTXD or DEBUG. It will be so much easier to have the PICAXE using a live data link with SERIN ( and SEROUT if needed ) while watching what is going on with another link for SERTXD and DEBUG.
 

radcom

Member
Thanks for suggesting AXEpad I didn't know it existed, the way is have been testing it is to send the data to the picaxe using the serial lead connected to my server then switching it to my PC running prog editor and debug, now I've installed Axepad and using the terminal in that I've found that my project works exactly how it should, but only with the Linux AXEpad's terminal or with windows.

So the problem must be with how Ubuntu sends out serial data. Has anyone else had problems send serial data to a picaxe from a Linux command line?
 
Last edited by a moderator:

hippy

Ex-Staff (retired)
The issue is probably how the tty port is configured at the command line level.

Programs like LinAXEpad will normally open the tty port with the correct settings so communications work. At the command line level you may have to mess about with 'stty' settings to get things right. I haven't done it but sending and receiving using perl should work, though you'll likely have similar problems if just shelling out to an echo command.

A search engine is probably your best friend here, the first one out the bag for me was -

http://linux.about.com/od/commands/l/blcmdl1_stty.htm
 
Top