000733
March 10, 2008, 4:00pm
1
Hello all,
I have taken an example code for Hexapod from here:
lynxmotion.com/images/files/eh3r220.bas
I am trying to use it for my hex. This example code is written in Basic syntax and is used for Bot Board / BASIC Atom 28
I am using OOPic and C style code, so I have a problem with understanding meaning of DEC in this line of code:
serout p15,i38400,"#",RRHH,RRHH2,“P”,DEC HipH_Pulse(0),"#",RRHV,RRHV2,“P”,DEC HipV_Pulse(0),
Is this DEC= decriment or something else, something specific for BASIC Atom? How can it be rewritten in C?
Other than that I have already re factored the rest of the code to oopic C style code.
Thank you for your replies. Your help will be greatly appreciated.
kurte
March 10, 2008, 5:35pm
2
000733:
I am using OOPic and C style code, so I have a problem with understanding meaning of DEC in this line of code:
serout p15,i38400,"#",RRHH,RRHH2,“P”,DEC HipH_Pulse(0),"#",RRHV,RRHV2,“P”,DEC HipV_Pulse(0),
Is this DEC= decriment or something else, something specific for BASIC Atom? How can it be rewritten in C?
The “DEC” modifier tells the compiler that you wish to output the value as Decimal ascii values not as a simple binary value. There are several ways to do this in C. For example you could call a simple function like “itoa” to convert the value, or more likely in C you would want to use something like printf to do the output and conversions.
Good Luck
km6vv
March 10, 2008, 5:40pm
3
DEC is some sort of formatting statement. You might want to download a copy of the Atom BASIC manual.
Try this:
printf("#%02dP%d#%02dP%d", RRHH, HipH_Pulse[RR_LEG], RRHV, HipV_Pulse[RR_LEG]);
Many things in Atom BASIC are typically done differently in C. Use #defines .
Replace “#%02dP%d#%02dP%d” with ServoStr1.
000733:
Hello all,
I have taken an example code for Hexapod from here:
lynxmotion.com/images/files/eh3r220.bas
I am trying to use it for my hex. This example code is written in Basic syntax and is used for Bot Board / BASIC Atom 28
I am using OOPic and C style code, so I have a problem with understanding meaning of DEC in this line of code:
serout p15,i38400,"#",RRHH,RRHH2,“P”,DEC HipH_Pulse(0),"#",RRHV,RRHV2,“P”,DEC HipV_Pulse(0),
Is this DEC= decriment or something else, something specific for BASIC Atom? How can it be rewritten in C?
Other than that I have already re factored the rest of the code to oopic C style code.
Thank you for your replies. Your help will be greatly appreciated.
I don’t know the OOPic C variations. How do you like OOPic?
Alan KM6VV
000733
March 11, 2008, 12:51pm
4
Thank you guys for your replies!
Tried both printf and itoa, but OOPic compiler could not parse them. Then I stumbled upon Str$ function in OOPic manual.
oopic.com/str.htm
“A function that takes an argument of a numeric data type and returns the argument’s value as a string written out as a decimal number.”
Am I understanding correctly, that it is the same as DEC in BASIC syntax?
At least when I have rewritten my code as follows:
SSC.String=("#"+RRHH+RRHH2+“P”+Str$(HipH_Pulse(0))+"#"+RRHV+RRHV2+ … etc
Compiler parsed it successfully and threw no mistakes.
I find OOPic to be quite useful for me. It can do everything I need and its easy to program. But I have no experience with Basic Atom and Bot Board, so I can’t compare these two.
km6vv
March 11, 2008, 4:52pm
5
Str$()? Sounds like BASIC.
Manual says OOpic has four “Syntax Compatibility Modes”. Something for everybody I guess.
What’s wrong with %d ? no printf()?
printf("#%02dP%d#%02dP%d", RRHH, HipH_Pulse[RR_LEG], RRHV, HipV_Pulse[RR_LEG]);
000733:
Thank you guys for your replies!
Tried both printf and itoa, but OOPic compiler could not parse them. Then I stumbled upon Str$ function in OOPic manual.
oopic.com/str.htm
“A function that takes an argument of a numeric data type and returns the argument’s value as a string written out as a decimal number.”
Am I understanding correctly, that it is the same as DEC in BASIC syntax?
At least when I have rewritten my code as follows:
SSC.String=("#"+RRHH+RRHH2+“P”+Str$(HipH_Pulse(0))+"#"+RRHV+RRHV2+ … etc
Compiler parsed it successfully and threw no mistakes.
I find OOPic to be quite useful for me. It can do everything I need and its easy to program. But I have no experience with Basic Atom and Bot Board, so I can’t compare these two.
It does appear to have a rich set of objects. But the details of controlling peripherals is hidden too much, imo.
Alan KM6VV