BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:59 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ARC32 sending garbage to BMS Terminal1
PostPosted: Sun Jan 23, 2011 3:04 pm 
Offline
Citizen

Joined: Sat Jan 15, 2011 10:01 am
Posts: 16
I have sort of a issue .. and since i cant find anyone else having tha same it probably is me doing something wrong

I have a simple code reading from a PS2 and displaying it to the Terminal1 in the Basic Micro Studio (2.0.0.7)
Code:
serout s_out,i38400,[0,"Right XAxis servo: ",sdec ((128-dualshock(2))*12000/127),13]

and it goes well and looks nice in the terminal windows
untill i tries to use the inputdata to, for example, drive a servo using hservo
Code:
hservo [p0\(128-dualshock(2))*12000/127]

(i get the same issue even when i just add a
Quote:
if(hservostate 33 < 310) then
even if it is never called)

instead of a nice and clean:

Right XAxis servo: -12000

i get

Righè XAxis sRiÏht XAxis seäÙ{éþ0ervßéþ0

What am i diong wrong ?
Are there any tweeking to to whing the USB-connection to my computer ?
According to the manual there are a possible error of 1.73% ... but this is more like 75% ...
I havnt got a special comport for my terminal window, i use the same port (COM3) as i do the programming by, is this a problem ?

_________________
PS
As i am both dyslectic AND Swedish, you may laugh at my spelling and grammar, but please please don’t comment it if you understand what i mean
DS


Top
 Profile  
 
 Post subject: Re: ARC32 sending garbage to BMS Terminal1
PostPosted: Sun Jan 23, 2011 3:45 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Hi Kurt here,

yes serouts are somewhat toast at higher speeds when you have something active that does interrupts. This includes such things like HSERVO, HSERIAL, ...

The good news is you are using an Arc32, which has hardware serial on the S_IN/S_OUT pins. Which is why on Arc32 I do all my debug outputs using hserout...

Remember to initialize the hardware port, like:
; using HSEROUT for debug messages...
sethserial1 H38400

You will see this in my Arc32 phoenix code.

Kurt


Top
 Profile  
 
 Post subject: Re: ARC32 sending garbage to BMS Terminal1
PostPosted: Mon Jan 24, 2011 4:01 pm 
Offline
Citizen

Joined: Sat Jan 15, 2011 10:01 am
Posts: 16
Thanks, it works like a charm ! 8-)

_________________
PS
As i am both dyslectic AND Swedish, you may laugh at my spelling and grammar, but please please don’t comment it if you understand what i mean
DS


Top
 Profile  
 
 Post subject: Re: ARC32 sending garbage to BMS Terminal1
PostPosted: Wed Feb 02, 2011 1:18 pm 
Offline
Citizen

Joined: Sat Jan 15, 2011 10:01 am
Posts: 16
OK, now i present problem no 2 on the same tema:

In the code I first INIT the AUX1:
SetHSerial2 H300,H8DATABITS,HNOPARITY,H1STOPBITS

then i try to use it by
hserout 2, ["c"]

... and what i get is a prerfect
N

:twisted:

ok, next try, i write
hserout 2, ["C"]

... and what i get is a prerfect
^

:evil:

Am i stupid o what am i doing wrong ?
If i try it on the USB-connection it all works fine, ie what i print using hserout shows in the terminal
I am saying "perfect" but it isnt 100% perfect, for example the terminal is cleared betwen each print, so there has to be more writing than what i can see.
It has no influence if i use hserout 1 on the same time, the result is the same
I am using a USB to Serial converter and BMS, but i have _exactly_ the same result on an old portable (whith an onboard serial) using Hyperterminal
I am not using any interupts or anything, not any servoes (yet)
the cable is a very simple
RS323-Dsub9 <-> 0.1connector on ARC32
pin2 RX pin3 TXD2
pin3 TX pin5 RXD2
pin5 GND pin7 GND

This is very irritating !


compleate program:
Code:
SetHSerial2 H300,H8DATABITS,HNOPARITY,H1STOPBITS
main:
hserout 2, ["C"]
Pause 100
goto main

_________________
PS
As i am both dyslectic AND Swedish, you may laugh at my spelling and grammar, but please please don’t comment it if you understand what i mean
DS


Top
 Profile  
 
 Post subject: Re: ARC32 sending garbage to BMS Terminal1
PostPosted: Wed Feb 02, 2011 1:40 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Have you tried a higher baud rate and see if that works? On Bap28s I normally do debug outputs at 9600 baud and with Arc32 with hserial I often do 38400

Am I missing something? You are connecting TX2 and RX2 directly up to an RS232 cable? The outputs of TX2/RX2 are TTL level signals (0-5v), and RS232 cables expect and deliver RS232 level signals, which can be something like -12v to +12V... or something like that). To connect an RS232 level signal you need a level shifter, something like a MAX232 chip or the like. Or you can use something like an XBee which has it built in.

Alternatively (and I have never tried), I have read that you can cannibalize an RS232 to USB adapter cable and connect up you TTL level signals. Again I never tried it, but have seen posts on this.

Kurt


Top
 Profile  
 
 Post subject: Re: ARC32 sending garbage to BMS Terminal1
PostPosted: Wed Feb 02, 2011 2:14 pm 
Offline
Citizen

Joined: Sat Jan 15, 2011 10:01 am
Posts: 16
imbarrising, of cource it can't be done, thats why i dont succeed ... i just imagined having a debug terminal connected to the AUX1 allways online so i dont have to connect after each recompile ... i didnt think about the different levels

(i had the same problems with all baudlevels i tried, but whith 300 the result was so clear, whitch is good for demonstration)

Time to get a XBEE then... :D There are allwayes something new to buy !

_________________
PS
As i am both dyslectic AND Swedish, you may laugh at my spelling and grammar, but please please don’t comment it if you understand what i mean
DS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO