|
|
European based company with global Delivery
________________
________________
________________
If you need support with our products then click here to register > Support Centre
________________
_________________________
________________
News Feeds
You Tube Morphogenesis: Shaping Swarms of Intelligent Robots
______________________
What is Biomimetics? It is the abstraction of good design from Nature.
|
Basic Stamp Programming Examples This section covers some example programming code for all the Infrared Control Freak command codes. The code is written for a Basic Stamo (BS2) Output results are in decimal formats. However if you replace the 03x with a 04x, the outputs will be in ASCII format (i.e. for direct connect to Terminal screen)
COMMAND 032 ONE-SHOT IPRD The Basic Stamp program below will trigger the Infrared Control Freak (IR-CF) into the ONE-SHOT IRPD. In this command IR-CF will send 100 pulses on the left and right IR LED's. IR-CF will then check on each sensor for reading of obstacles. The measured results are sent as 6 bytes of data. The values will be in the range 0-100. The value 0 = the sensor has not detected any obstacle. On the other extreme, a value of 100 = that the obstacle is almost about to collide with the IR-CF. The first two bytes are the results from the right sensor. The first byte is the measured hits from the Right LED and the second byte is the number of hits from the LEFT LED. Unless the obstacle is extremely close, the right sensor should not actually 'sense' any 'hits' from the LEFT LED. As depicted in diagram below the obstacle will be sensed only on the left and middle sensors. The sequence of Bytes returned to the Basic stamp are:
The most important bytes to measure are 1, 3,4 & 5. Simple Programming See below how simple it is to interface to the IR-CF using the Basic Stamp. Just a few lines of code and you'll be up and running: _________________ '{$STAMP BS2} 'Test Command 032 - Single Shot
RX VAR BYTE(5) DATA_ARRAY VAR BYTE '*************************** '* MAIN PROGRAM * '*************************** MAIN: GOSUB COMMAND_0 32GOTO MAIN '*************************** '* SUBROUTINES * '*************************** COMMAND_032: SEROUT 2, 16468, [ 32]FOR DATA_ARRAY=1 to 13 SERIN 4, 16468,1000,time_out, [RX(DATA_ARRAY)] NEXT
FOR DATA_ARRAY = 1 to 13 DEBUG dec RX(DATA_ARRAY), " " NEXT DEBUG CR debug "____________________________",cr RETURN
TIME_OUT: DEBUG "TIMED OUT", CR RETURN ________________________________
COMMAND 035 AUTOPILOT
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Copyright ROBOTmaker ©
2003. All
rights reserved.
|