Hello everyone,
I want to use MDA300 relays and digital I/O as ON/OFF control commands
for off-board equipment. My problem is that the state of the relays
and the I/Os don't change - all the I/Os are high and relays are not
energized.
I have tried both the interface (Relay) provided by Xbow and direct
manipulation of the I/Os by writing desierd states to PCF8574A using
I2C bus, but none of them worked :(
I noticed that the PCF8574A outputs never go low and they are always
high no matter what I write to the port. My code for doing this is as
follows:
configuration I2C_RelayC{}
implementation{
components Main, I2C_RelayM;
components TimerC, LedsC;
components I2CPacketC;
Main.StdControl -> I2C_RelayM.StdControl;
Main.StdControl -> TimerC;
Main.StdControl -> I2CPacketC;
I2C_RelayM.Leds -> LedsC;
I2C_RelayM.OnOff -> TimerC.Timer[unique("Timer")];
I2C_RelayM.I2C_Relay -> I2CPacketC.I2CPacket[0x3F];
}
module I2C_RelayM{
uses {
interface I2CPacket as I2C_Relay;
interface Timer as OnOff;
interface Leds;
}
provides {
interface StdControl;
}
}
implementation{
enum{
ONOFF_CYCLE = 100UL,
RELAY_ON = 0xAA,
RELAY_OFF = 0x55
};
uint8_t relayStat;
command result_t StdControl.init(){
call Leds.init();
return SUCCESS;
}
command result_t StdControl.start(){
call Leds.greenOn();
relayStat = RELAY_OFF;
call OnOff.start(TIMER_REPEAT,ONOFF_CYCLE);
return SUCCESS;
}
command result_t StdControl.stop(){
call OnOff.stop();
call Leds.redOff();
call Leds.greenOff();
call Leds.yellowOff();
return SUCCESS;
}
event result_t OnOff.fired(){
if (relayStat == RELAY_OFF){
relayStat = RELAY_ON;
call Leds.yellowOn();
call I2C_Relay.writePacket(1,(char*)(&relayStat), 0x01);
}
else{
relayStat = RELAY_OFF;
call Leds.yellowOff();
call I2C_Relay.writePacket(1,(char*)(&relayStat), 0x01);
}
return SUCCESS;
}
event result_t I2C_Relay.writePacketDone(bool result) {
call Leds.redToggle();
return SUCCESS;
}
event result_t I2C_Relay.readPacketDone(char length, char* data){
return SUCCESS;
}
}
I have read the massage posted by Marco Maniezzo (Thu Jul 21 02:15:52
PDT 2005 ), which indicates that the problem is due to TinyOs version.
However, as I am using TinyOS 1.1.11 installed from Xbow installation
CD, I don't think my TinyOS version is the problem. I will be glad if
any one let me know what I am missing and how can I get the relays and
digital I/O working.
Thanks,
Kaveh Lotfian.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help