Personal tools
You are here: Home sirblog Jal library for the MIC800 chip
About the SirBot Project
The SirBot Project is a framework on which you can easily build robots. Have a look at the SirBot Labs to see what can be done with it !
Here's the Tamabot DayCare, the bot that takes care of your tamagotchi !!!

And the SirBot Ranger is able to measure distances, and detect obstacles such as fruits...
« September 2010 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Recent entries
Face detection with Nokia N900, using ROS and OpenCV sirloon 2010-08-26
ROS on Nokia N900 sirloon 2010-08-19
Since last post... sirloon 2009-01-18
PCB using toner transfer method: video and comparison sirloon 2008-08-01
New boards available from SirBot sirloon 2008-06-16
 
Document Actions

Jal library for the MIC800 chip

by Sébastien Lelong posted at 2007-01-16 10:45 last modified 2007-02-08 15:07

During the Jal migration of the SirBot Project, I had to write some jal libs (my very first ones). One of them is used by the TamaBot and the SirBot Ranger, to control servos. The sb_mic800 library is able to handle the MIC 800 chip, and thus the servo controller board.
The MIC 800, from Mictronics, is a quite expensive chip which can control up to 8 servos. Commands are sent via a serial com. @2400bds.
Ex: sending "SA103\r" will make the servo A moving to position 103.

The first version of the servo controller board was using the built-in USART of the PIC16F628 to send those chars. But the USART was also used to communicate with the PC. There was a baudrate switch (from 19200 to 2400) each time the MIC 800 was accessed, but while sending chars to the chip, those were also sent to the PC... Fortunatly, due to baudrates differences, every things worked quite well: the PC didn't received chars which could be misinterpreted... But this was far from clean.

Thanks to Jal and its libraries, putting another serial com. within a 16F628 is trivial. Just need to use the serial_software lib. The sb_mic800 library used here just  declare another USART, software coded. No more baudrate collision ! This setting has been taken from the Great Bert's starterpack for the 16F628, which can be found here.

So here's what the sb_mic800 lib can do, illustrated in this example:

  • First include the lib
include sb_mainboard ; or 16f628_bert
include sb_mic800
  • Each servo can be accessed via SERVO_A, SERVO_B,..., SERVO_H vars. Let's declare synonyms. The code will be easier to understand.
var byte volatile ROTATIVE_SERVO is SERVO_A
var byte volatile PUSHING_SERVO is SERVO_B
  • There are getter and setter func to access servo's information
var byte servo_rotative_min_position =
get_servo_info(ROTATIVE_SERVO,MIN_POSITION)
-- big step for pushing servo
set_servo_info(PUSHING_SERVO,SERVO_STEP,34)
-- but not too much...
set_servo_info(PUSHING_SERVO,MAX_POSITION,86)
  • OK. Let's actually move a servo
-- move the rotative servo
move_servo(ROTATIVE_SERVO,103)
  • Servos can also be moved by steps
-- push
increment_position(PUSHING_SERVO)
-- pull
decrement_position(PUSHING_SERVO)
  • All servos' information (current/min/max position + step) can be saved into EEPROM...
save_positions()
  • ... so can load them later, and continue the job !
load_positions()	; will set current/min/max positions + step,
  ; and move all servos to previous positions



Some works still need to get done, such as the possibility to calibrate all the servos positions (that is, setting their min/max positions and their step), and switch into a "check mode" which will... well check the sent commands are valid ones (occured between allowed positions).

The sb_mic800 lib can be downloaded here.
Category(s)
SirBot Project
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)
(Required)

(Required)

Powered by Plone Powered by Gentoo