Openservo v 2.7 and Picaxe

kolber

New Member
Hello,
I have OpenServo from SparkFun http://www.sparkfun.com/products/9014
and I don't understand.
You do not have somebody experience, how him control in Picaxe code?

Thanks
Jan
 

nick12ab

Senior Member
OpenServo is an i2c servo controller. The PICAXE has very good and extremely easy to use i2c functionality. You connect the SDA and SCL pins on the openservo to the SDA and SCL pins on the PICAXE (check PICAXE Manual 1 to see which).

On to the quote below...
Setting the servo position

A standard I2C transaction at the byte level is simple. First you send the device slave address, and then you send the register to read/write to. After that is sent you can either write some data to the register(s) or read data from those registers. Address reading and writing is incremental, and as such when you read, or write more than one byte to any given start address, it will automatically increment the pointer position.
For example, to set a servo position of 980 (which is the max value I can get from a Stell Servo) you would send this command sequence.
Assuming device address = 0x20
I2C communicates using hex bytes, so position 980 translates to 0x03D4
As with any I2C transaction, this 16 bit value must be split into 2 8 bit bytes. All that is required, is to send the upper and lower nibbles of the byte.
send: 0x20 0x10 0x03 0xD4

Setting the position and speed

When writing a speed to the servo, you don't use the standard seek register. Instead of writing to SEEK_HI/LO (0x10/0x11), you must write to the SEEK_NEXT_HI/LO (0x12/0x13).
The servo will not perform the movement until a valid speed variable is set with either of the two speed algorithms available.
There are two methods of speed control of a servo, Accumulation based speed and Time based speed.
Speed based works this way.
It appears that the default i2c address is $20, so you'd use that as the address in the hi2csetup command in PICAXE (hi2csetup i2cmaster,$20,i2cfast) but the terrible documentation doesn't say whether that includes the read/write bit, so if it doesn't work with this, you need to use $40 instead which is everything shifted left by one bit.

You then use a word variable on the PICAXE and send out two byte variables to the controller using hi2cout. PICAXE has really good memory management (unlike Sparkfun's favourite, the Arduino, which has terrible memory management) so you simply send the two byte variables that share the same memory has the word variable - so if you're using w1 you'd send b2 and b3 or if you're using w2 you'd send b4 and b5. The lower number byte is the least significant.[hr][/hr]If you are only controlling one or two servos, consider using the servo command on the PICAXE which eliminates the need for this module.
 

kolber

New Member
Hello
Thanks, felt I'm it, but nothing.

'OpenServo
'************************************
#Picaxe 18X

main:
i2cslave $20, i2cslow, i2cbyte
writei2c $10,($03,$d4)
writei2c $12,($01,$00)
end
 

hippy

Ex-Staff (retired)
On to the quote below...It appears that the default i2c address is $20 ...
Or is "assuming" $20 just an example ? The last paragraph on that page suggests the default is $7F for all until configured otherwise.

I'd try with a slave address of $FE.
 
Top