PDA

View Full Version : garbage var from pulsin,,



PICMAN
- 21st February 2005, 01:56
ok im using a bs2, to test something, i was using this code,

________________

PAUSE 250
PLS VAR Word

main
PULSIN 15, 1 , pls ' recieve hi pulse store in pls varible
DEBUG pls

GOTO main

__________________


my goal is to see what kind of varible comes up at certian points,, , with pin 15 conected to the signal wire off of a futaba reciever, it seems to work, but this is what the varible reads,

___
0Ëê 3:
 t
___


i was expecting a number read out, around150 , or 1.50 , which would be the pulse that operates a servo, any help turning the jiberish i got into the numbers i expected?i suspect im missing a bit of code, to tell the bs2 how to decipher the signal its recieving

as expected,, i did infact get a change in the out put of the debug terminal, when i controled the reciever via remote , only i am inable to compare the jibberish i got,

fyi using 10 k ohms resistor betweensignal wire and input pin 15 on bs2, plan to build using pic just testing with what i got

mister_e
- 21st February 2005, 03:18
what about if you use DEBUG #pls or serout with # before the variable

PICMAN
- 21st February 2005, 03:39
doesn't reconize character "#" for debug, and im not fdamilar with serout,

debug opens a window and displays the info,

serout,, im not sure, and think id need more stuff to make that work,

mister_e
- 21st February 2005, 05:58
i'm sorry i've and i'll never work with those Basic Stamps... of course there's something on their website or in your basic stamp programming book. DEBUG must have something like # or DEC or else function to be place before your variable.

If you send the value of a var... let's say your var=149... you'll send the ASCII character 149 wich is ò... this is why you have garbage IMHO.

◘Ã╚╔♀∟Ã

PICMAN
- 21st February 2005, 06:30
ok , dec worked, now i get numbers ,, but from what i can see there random,

heres the code im using now,

__
PAUSE 250
PLS VAR Word

main
PULSIN 15, 1 , pls ' recieve hi pulse store in pls varible
DEBUG DEC pls

END
__


i stopped it from looping because i got tons of numbers, i take 4 readings at zero,, and get,,
6, 1 , 9 , 30
this is with out effecting servo placement,
effecting full left,
8 , 1 , 7 , 9
full right
5 , 8 , 62 , 9

ive got to have something wrong, these results dont match up, in the debug window it says 9600 baud, im confused by this, i expected to see 1.50 at zero, 1.25 1.75 etc. any sugestions?

mister_e
- 21st February 2005, 13:50
i don't know the default debug baudrate for those BS chip but can you select 2400 baud ?!?

PICMAN
- 21st February 2005, 18:05
hmm , well i got it set to 2400 , but inorder to do that, it discards all my formating comands and imback to ascii, i was thinking may the reason for junk out put, be that im sposed to count up 16 or 20 times, cause its 20 u seconds, that tells the servo what to do i think im taking partial readings,

for pulsout, theres a counter loop above the output, inorder to time it, i think my issues here is not reading in sections, im getting a flowing reading , and i need 20 u second intervals,

also id like to add, i saw the symbol for 149 rather freequently, is there a chart of ascii text, maybee, i need to refer to the amount in ascii txt for this to work , if i could map out the values we know will be here i can decipher ascii, now im thinking , at 2400 baud its working but i am inable to convet to # data i did see the symbol for 149 alot, but think i need to alsop put in timing or similar to make this work

PICMAN
- 21st February 2005, 19:49
ok, ive decoded the VAR, at "zero" it does infact read 149 , and it does apear correct, if i use 2400 baud, on pic, it will get the readouts i expect, now mr e , can u tell me where to start lookin into to declare logical parameters using ascii,

for instance

___
if PLS = (o with 2 dots above it) then rled = 0 : lled = 0

___

also ive not found a table of ascii , from 1 - 200, i find 1- 12x, and then a seprate one for 12x - 200 , from my reading i find that the "extended ascii" tables are posibly not standard,

is there a peritcular one that i can depend on bieng standard for pic use,

how do i refrence ascii characters, this is compleatly new to me

mister_e
- 21st February 2005, 20:19
well what to say to this one. If you receive your data with the PIC it will be already the great value, don't mix Terminal operation and PIC operation..

If by example your PC will get your value from the PIC, you can only send it like this
SEROUT PORTB.0,4,[Myvar1,Myvar2,Myvar3]

and leave it like this. Your PC software will get the right value of your var. Case you want to work with string, you'll have to get each character and do the ASCII to decimal conversion... not handy and so much time spending.

PIC to PIC. Send your data same as above and receive the same way.

Master: SEROUT PORTB.0,4,[Myvar1,Myvar2,Myvar3]

SLAVE : SERIN PORTA.0,4,[Myvar1,Myvar2,Myvar3]

OR maybe i didn't understand your question....

Sending text+Value of a var on a terminal:
SEROUT PORTB.0,4,["Myvar1 : ",#Myvar1," Myvar2 : ",#Myvar2,13,10]

PICMAN
- 21st February 2005, 20:31
indeed i was not clear, when i use purely ascii, i get prouduct i ecpect, for example 149 at zero,, but if i try to convert to DEC it gives me junk, i wish to use logic to say

if PLS = 143 - 153 then rled =0 : lled = 0
if pls > then 153 then lled = 1
if PLS < 143 then rled = 1

my problem, is the only way i can see to refrence the varible, is in ascii format, so i need to know how to type ascii text, in my pbp program,

finished prouduct will have NO serout and will be self running, no pc conected, i just conect bs2 to pc to see how i can interact with var PLS,, which i have found i get the numbers i expect with out hassle in ascii format,, so i believe if i can use ascii formatt in my program ,, i can logically creat a flow, like above, but with out dec format,, not 149 , o with 2 circles above, but i am unsure if i can use ascii in program , i know for bianary i use %0000 0000,, i call this refrencing bianary, how do i refrence ascii, and how do i type out ascii characters,

originally i planed to use code identical to above, but i find isues when i tell debug to read out dec format, so since i get numbers i know are what i need in ascii, i wish to refer to these values in ascii, to prevent garbage results, since ascii gets me what i need, and shows corasponding interaction when i controll sevo via remote , values change acordingly
in dec format they donot

or am i over thinking this, if i type code as above will it work, it seems to me the pic should know 149 = o with 2 circles above, (ascii )

mister_e
- 21st February 2005, 21:23
you can't refer to ascii to do your stuff.

if (PLS <153) AND (PLS> 143) then
rled =0
lled = 0
endif
if pls > then 153 then lled = 1
if PLS < 143 then rled = 1

this already work as you wish.

you can also refer to binary
if (PLS <%10011001) AND (PLS> %10001111) then
rled =0
lled = 0
endif
if pls > then %10011001 then lled = 1
if PLS < %10001111 then rled = 1

Or in hexadecimal
if (PLS <$99) AND (PLS> $8F) then
rled =0
lled = 0
endif
if pls > then $99 then lled = 1
if PLS < $8F then rled = 1


If you want to receive value from PC and convert it to decimal
SERIN2 PORTB.0,16780,[dec3 loop]

this will receive 3 character and convert it to decimal value from your terminal.

If you want to send 123 to pic type 123, if you want to send 10 type 010 and that's it

PICMAN
- 21st February 2005, 21:40
awsome so i was thinking to hard, if i read 149 at "zero" (in ascii text off bs2)
then i can refer to this value in pbp, as 149 and it will work,

this means my design works perectly,

ty

PICMAN
- 28th February 2005, 17:31
ok, the numbers we were thinking are too low look around the 700 regon,, connect the servo batery negitive to the bs2 or pic - power suply,, since the pulse is sent on hi,,, the negitives must be conected for the ic wether (pic or bs2) and the servo pack, other wise you get the junk output, once this conection is made every thing works ,, with dramatically simple coding