030 - Infrared Proximity sensing - 360 degrees
Summary - 360 degrees Infrared Proximity sensing
30 <BYTE2> <BYTE3> <BYTE4> (decimal format)
BYTE1: 30 (the command)
BYTE2: Zone (default zone =10) - See description for details
BYTE3: 01 = Decimal Output
BYTE3: 02 = Ascii Output
BYTE3: 03 = Ascii Output - Delimited
BYTE4: 0= single shot operation
BYTE4: 255 = continuous operation-
Response from IRCF360:
Average proximity readings from each direction:
Decimal format: <N> <NE> <E> <SE> <S> <SW> <W> <NW>
Ascii Format: N= <N>, NE= <NE>, E= <E>, SE= <SE>, S= <S>, SW=<SW>, W= <W>, NW= <WN>, 013 (Carrage return)
Ascii Delimited: N= <N>;<NE>;<E>;<SE>;<S>;<SW>;<W>;<NW> 013 (Carrage return)
Circular Display Feedback:
If an object is detect in any direction the corresponding LED will illuminate (see videos)
360 degree proximity sensing. All 8 IR transmitters are triggered in turn and the results are interpreted for proximity information.
Byte 2 determines the zone of the reading. sensitivity of the readings. This is useful when filtering of objects at certain distances need to be made.
The value adjust the carrier frequency of the infrared signal and influences the sensitivity of the IR receiver. The peak sensitivity frequency of the infrared receiver is 38KHz (see notes Zones ). The default value is 10, which gives best readings for smaller robots with a proximity sensing range of about 100mm, which depends greatly on colour of material. .
The values between 9-11 should be entered. If 0 is entered then the default value of 10 us used. Experimentation with different values should take place to see what works best with your own robot project. See more discussion of zones on the following webpage- > Zones.
Byte 3 determines the output format, either decimal, ASCII or ASCII delimited.
Byte 4 determines whether the scanning should stop (0) after one loop or continue (255).
8 raw bytes of serial data (proximity information) are transmitted to the serial port.
Values from 0 to 100 are returned for each direction starting with the N (north) direction and then NE, E, SE, S, SW, W, NW. In total 8 bytes of data are returned. each byte depicting the reading in each direction.
The command can be used for:
Used in swarms and flocks. Specifically within flocks where a constant distance to a neighbouring flock member needs to be maintained to ensure collective patterns
proximity sensing when travelling in a direction and at the same time monitoring objects that may be moving towards it.
executed when in a stationary position to make assessment of the stationary objects or object that are moving.
Determine and avoid possible attacks when in robot gaming mode
The IRCF360 receives a 12-bit infrared package which is split between button code and device code. Sony also use a 15-bit version which does not work correctly with this command as 3 bits of information will be missing. See "Principle of IR remote control" for more details
The PICAXE 18X does not have a 'time-out' function, so it will 'hang' if the timing of the serial communication is not correct. With the new X2 parts these have a time-out routine so the command can be retransmitted. For examples see the attachments at the end of this section
Example Programming Code for PICAXE
' on port b.2 send one-shot 360 degree infrared sensing command, at 9600 baud, for zone 10 with decimal output
SEROUT b.2,T9600_8, (30,10,01,0)
SERIN 2,T9600_8, N, NE, E, SE, S, SW, W, NW
Example Programming code for Basic Stamp
For Basic Stamp
'On port 2 send one-shot 360 degree infrared sensing command, at 9600 baud, for zone 10 with decimal output
SEROUT 2, 84, [30,10,1,0]
' On pin 3 receive 8 bytes of data at 9600 baud. go to label timeout after 1 second if no data arrives.
SERIN 3, 84, 1000, TIMEOUT, [N, NE, E, SE, S, SW, W, NW]
SEROUT 2, 84, ["Timeout"] Exmaple
This next video shows the IRCF360 sensor module mounted onto of a robot controller (in this case a PICAXE 18x). The robot controller is sending the command 30 to the IRCF360 sensor to trigger the 360 degree proximity sensing mode.
Via the via the RS232 serial interface the sensors replies back to the robot controller with information of all the proximity values from all 8 directions The robot controller can then decide which direction to turn.
The main robot controller routine written in PICAXE basic is as follows (The full listing is attached in section below):
' Main Program
IF NE > 30 then
IF NW > 30 then
IF SE > 20 then
IF SW > 20 then
IF E > 20 then
IF W > 20 then
IF N <=44 then
IF N >=45 then
'This next part counts how many times the robot is hunting backwards and forwards. If it does it 3 times then it must be stuck so
' turn in a direction based on the highest sensor readings.
IF backup_count > 3 then
if NW > NE then gosub turn_left
if NW <= NE then gosub turn_right
'if there is something behind the robot then go forward
IF S > 20 then GOSUB forwards
GOSUB blink ' Blink the LED to indicate power-up
In this next demo, just the the NW, N, NE and South directions were being checked for obstacles by a robot controller with a PICAXE (reved) microcontroller installed and a pololu motor controller.
A very simple program was written which just moves the robot in the opposite direction of the obstacle and then stop.