Products
Technology
SMS solutions
PBX systems
Databases
Robotics
Building robot hardware
Building electronics
Building robot software
Introduction/Protocols
Architecture
How to develop a devhandler
Line protocol
DeviceHandlers
Oz433Mhz Transceiver
OzAnalogJoystickController
OzAnalogSensor
OzBatteryController
OzBuzzerController
OzButtonController
OzDCMotorControllerL298N
OzDHTController
OzDoorphoneController
OzEEPROMController
OzKeyboardController
OzGyroscopeSensor
OzIDManager
OzIRTransceiver
OzLCDController
OzNfcReader
OzOpticalGateController
OzRegisterManipulation
OzRF24Transceiver
OzRGBLEDController
OzRotaryController
OzServoController
OzStepCounter
OzStepperMotorMultiController
OzSwitchController
Example
OzTemperatureController
OzTimer
OzUltrasonicSensor
Examples
Bootloader
Company


OzSwitchController

Every OzSwitch Controller devicehandler has a single pin. This protocol can set it's own PWM pin to either HIGH or LOW or you can modify the PWM. For example you can control a relay with HIGH or LOW signals or set the brightness of a LED by changing the PWM.

If you connect it to a digital pin with no PWM than a 0-127 PWM value counts as LOW and 128-255 PWM value counts as HIGH state. For example the default pin is D13, which has no PWM capability, although D13 is digital.

How to build a test circuit with a LED and an Arduino Mega?
Arduino codes are included.

I. 'Welcome' message from microcontroller

c=welcome&type=OzSwitchController&id=IqlZci&pos=2&t=3

Parameters

Parameter Type Range Functionality
c String 'welcome' Identifies the welcome message.
type String 'OzSwitchController' Determines the type of the device.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
pos Byte 0-255 Determines the position of the device on the list of the ID manager of the microcontroller. Please make sure there are no other devices in the same position.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



II. Commands to microcontroller

'Switch On/Off' command

It sets the pin of the switch to a constant HIGH or LOW state. If a PWM signal was set before than this command will disregard it.

Example

//Turn On
c=setswitch&state=1&t=0&id=IqlZci
//Turn Off c=setswitch&state=0&t=1&id=IqlZci

Parameters

Parameter Type Range Functionality
c String 'setswitch' Identifies the command.
state Bool 0,1 0 sets switch to LOW STATE,
1 sets switch to HIGH STATE.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.

Response

//Turn On Response
c=setswitch_resp&state=1&pwm=255&id=IqlZci&t=1
//Turn Off Response c=setswitch_resp&state=0&pwm=255&id=IqlZci&t=2 //'pwm=255' is irrelevant. Only state was changed by command. //And the statechange overwrites the pwm signal.

Parameters

Parameter Type Range Functionality
c String 'setswitch_resp' Identifies the response.
state Bool 0,1 If 0 the switch is set to LOW STATE.
If 1 the switch is set to HIGH STATE.
pwm ushort 0-1023 THIS IS IRRELEVANT IN THE CURRENT CASE
(Pulse-Width Modulation value.)
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



'PWM change' command

If this Switch Controller device is connected to a PWM pin than this command can change the PWM value.

If it is connected to a digital pin with no PWM then it will work as a 'Switch On/Off' command.
In this case 0-127 PWM value counts as LOW and 128-255 PWM value counts as HIGH state.

Example

//Please do not use 'state=...' parameter
//since it overwrites the 'pwm=...' parameter.
c=setswitch&pwm=204&t=2&id=IqlZci

Parameters

Parameter Type Range Functionality
c String 'setswitch' Identifies the command.
pwm Ushort 0-1023 Pulse-Width Modulation value.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.

Response

//The 'state=...' is irrelevant. Only pwm was changed by command.
//'pwm=255' is equal to pin set to HIGH (state=1)
//'pwm=0' is equal to pin set to LOW (state=0)
c=setswitch_resp&state=0&pwm=204&id=IqlZci&t=3

Parameters

Parameter Type Range Functionality
c String 'setswitch_resp' Identifies the response.
state Bool 0,1 THIS IS IRRELEVANT IN THE CURRENT CASE
(If 0 the switch is set to LOW STATE.
If 1 the switch is set to HIGH STATE.)
pwm Ushort 0-1023 Pulse-Width Modulation value.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



III. Event from microcontroller

None
Copyright © 2000- - Ozeki Informatics Ltd. | info@ozeki.hu | Tel: +36 1 371 0150
Home > Technology > Robotics > Building robot software > Introduction/Protocols > DeviceHandlers > OzSwitchController
Page: 1577 | Login