Intellecta Technologies Pty Ltd

for PICAXE education, Roland CAM, Techsoft CAD, Intellecta control, Atmel, Arm and Microchip education

Control7 sensors03

Using Sensors

Sensors are electronic devices that record variables such as pressure, temperature, light intensity and other values. They differ from switches because they are analog devices that can have any value. A switch can only be ON or OFF.

Control 7 has two sensors that can read a sensor and produce a value that corresponds to an input from ) to 5V. The actual accuracy is given by the software.

This program is the simplest way to read the sensors and see the value.

Sensors are read on IN1 and IN2 with the readadc command.

This command needs to have the sensor input AND where the sensor value is stored.

readadc, input, value

readadc input1, lightvalue is a possible BASIC command if input1 and lightvalue have defined values.

 


Setting up test program

The test program can be designed in the Flowchart editor with only two icons.

The sensor must be read and that is performed with the readadc command.

Note that you cannot define the name of the sensor input from the Flowchart symbol table. However, you can enter the destination of the data by choosing the variable called lightvalue that you have entered. You can change the value when you go to the Convert Flowchart to BASIC option.

Run the simulation and you can change the value of Lightvalue by sliding the Analogue bar around.

Sensor test

Download the program

When you download the program to the real Control 7 you can see the sensor value in the debug window as you move the sensor. We used a light sensor.

Note that you can change the readadc 1, lightvalue to readadc sensor1, lightvalue to preserve the ease of reading the sensor values.

Take a note of the readings to get an idea of the typical values for dark and light conditions.

light sensor debug basic code

 

Setting up a real program with Motors and lights

This examples pushes you a little harder by setting up a problem. You want the light value to be recorded and then turn on the motors and lights. The directions have to control 2 motors and 2 lights.

This example shows you the easiest way to control these number of devices with the pins command.

Place the icons and link them as in the figure below.

The IF lightvalue > 68 sets up a comparison point . The let pins = 0 commands are stubs or empty lines because it is difficult to work out the binary values that correspond to the light1, light2, motor1, motor2 values.

You will fill in the values when you convert the flowchart to BASIC.

Sensor control of the motor

 


Binary values and the pin command

You can see that the light1, light2 and the motor directions are all on one port or group of lines.

This means you can set the lines with the pins command. Some compilers can use commands such as Let PIN3.1 = ON in a similar manner.

However, converting binary values to decimal equivalenst is not that easy and so most high level microcontroller systems represent constans in decimal, binary or other systems.

Therefore we can write:

let pins = %00000001 to turn on the last device on the port.

The process is two step : convert the flowchart to BASIC and then set up the appropriate values.

binary constant

Step 1

Here is the result of the conversion to BASIC from the flowchart.

binary  entry into motor control

Step 2

Here you fill in the values of the pins command to reflect the actual value required. Check the values against the circuit schematics or the Flowchart Symbol Table.

Download this program and you should see the lights and motors come on and change directions as you change the sensor value.

 

binary control
[Home] [About] [News] [Events] [Products] [CAD] [CAM] [Control] [Mechatronics] [Science] [Materials] [Support] [Map] [Contact]

PICMicro & Microchip logo are registered trademarks of Microchip Technology Inc. AZ. Atmel AVR & Atmel logo are registered trademarks of Atmel Corporation. CA. Philips Logo is a registered trademark of Philips Semiconductor Inc & Philips SA, Netherlands. Picaxe is a registered Trade mark of Microchip. Intellecta is a registered trademark of Intellecta Technologies. All other logos and trademarks are the property of their respective owners.  Revision Date June2006

© 1997- 2006 Intellecta Technologies - All rights reserved - email: supportatintellectadotnet