PDA

View Full Version : wakeup pin not waking up the node


vijayaraj
05-15-2009, 07:45 AM
hi,
I am using a sleepy mesh scheme but without election as it does not require for my application.When master sends a sleep command , node sleeps during that time and wakes up sends the sensor value.In this,i would like to add a feature to node module.
When node is in Sleep mode,If user presses a button it has to wake up and send its address to master.I written the script, but the code could send the desired value when the node is in wake mode.If it is in sleep mode,after the button press it is not waking up and sending the data.I am showing my code below.


"""
"""
from synapse.pinWakeup import *

HIGH_RESOLUTION = 1

NV_DEVICE_TYPE_ID = 10

BUTTON_PIN = 1

DS_TRANSPARENT = 3

DATA_FREQUENCY_SEC = 0

NV_DEVICE_TYPE_ID = 10

DS_PACKET_SERIAL = 6

DS_STDIO = 4

DS_UART0 = 1

DS_UART1 = 2


def startupEvent():
"""run automatically after unit startup or download"""
global sleepMode,deviceType,blinkLED,msCounter
sleepMode = HIGH_RESOLUTION # high resolution Timer
setPinDir(0, True)
blinkLED = False
setPinDir(BUTTON_PIN, False)
setPinPullup(BUTTON_PIN, True)
msCounter = 0
monitorPin(BUTTON_PIN, True)
buttonState = readPin(BUTTON_PIN)
wakeupOn(BUTTON_PIN,True,False)


def sendSensorData():
global adcValue
global nodeAddress
adcValue = readAdc(0)
nodeAddress = "FFF321"
rpc("\xFF\xF3\x2C","sensorData",nodeAddress,adcValue)


def identifyToMaster():
global nodeAddress
nodeAddress = "FFF321"
rpc("\xFF\xF3\x2C","nodeIDinfor",nodeAddress)

def buttonEvent(pinNum, isSet):
"""Hooked into the HOOK_GPIN event"""
global buttonState
if pinNum == BUTTON_PIN:
buttonState = isSet
if not isSet:
identifyToMaster()

def gotoSleep(duration):
"""this is the actual "going to sleep" code"""
global sleepMode
sleep(sleepMode, duration)
afterSleep()


def afterSleep():
sendSensorData()

snappyGen.setHook(SnapConstants.HOOK_STARTUP, startupEvent)
snappyGen.setHook(SnapConstants.HOOK_GPIN, buttonEvent)

can you please tell me what is going wrong in the script.My objective is to wake up the module send the data when it is in sleep period.I am using EK2500 Kit.

msellers
05-16-2009, 12:42 AM
I don't see where you are ever calling the gotoSleep command unless you are doing that with a click in Portal. Is the buttonEvent firing? You can add statements like print "Button Pressed" in the event, intercept stdio in Portal, and see the lines in the event log to tell you whether or not you are reaching certain places in the code.

As an aside, there is no need to pass the node address as a variable in your function. This would require a different script for every node. rpcSourceAddr is available as a variable in any function that has been called by an rpc such as in your sensorData function.

vijayaraj
05-16-2009, 04:03 AM
Hi mSellers,
The script posted is the script loaded in the end node.The gotoSleep function will be invoked by the master(Bridge) node at the given time interval.The buttonEvent is working fine when the node is in wakemode.I dont have any issues in it.The only issue now i am facing is to wake up the node when it is in sleep(.i.e when master issues gotoSleep,end node will speed that time.)

kbanks
05-18-2009, 09:00 AM
You can add statements like print "Button Pressed" in the event

It is also often handy to use one or more LEDs (controlled by the script) to tell when a node is awake or asleep (hint - BLINK).

The only thing I saw in a quick read of your script was that you sometimes set variables within functions but do not declare them global first.

This means you are only setting a local (temporary) variable (that will go away when the function exits) - probably not what you intended.

Is the button press being maintained long enough for the node to see it?

You may need to use the built-in function setRate() to increase the pin sampling rate (look in the SNAP Reference Manual).

vijayaraj
05-18-2009, 09:06 AM
Hi Kbanks,
Thanks for the tips.Regarding the button press,yes it has been pressed for more than 1-3 second continuously.But even after release i could not find device waking up.But as per your suggestion,will increase setrate and will see the result.

vijayaraj
05-22-2009, 08:39 AM
Hi Kbanks,
Though increasing the set rate it is still not waking up when it is in sleep mode.Is ther any other settings i need to alter and see?

Jheath
05-22-2009, 10:47 AM
The buttonEvent is working fine when the node is in wakemode.

Vijayaraj, if you temporarily remove the sleep call and just monitor the buttonevent - do you see the rising and falling edge? In other words, if you put a debug statement "print "pin ",pinNum,"is ",isSet" into the buttonEvent function do you see it print twice (once for isSet = False and another time for isSet = True)?

vijayaraj
05-23-2009, 04:57 AM
Hello Jheath,
I modified the code as per your suggestion and the answer is YES,i do see it printing twice (once for isSet = False and another time for isSet = True).Then the other thing what i noted is,when i made the device to sleep mode using inbuilt function via portal and if i press the button,it is not printing anything in the hyper terminal, inferring it is not waking up.Can you give any more suggestions.

Thanks,
Vijayaraj.S

kbanks
05-26-2009, 08:13 AM
Several posts ago I suggested:

It is also often handy to use one or more LEDs (controlled by the script) to tell when a node is awake or asleep (hint - BLINK).


Have you tried this? This will tell us if it really is a "failure to wake up" versus a "failure to get a message through to Portal because the OTHER nodes are still sleeping".

vijayaraj
05-26-2009, 08:16 AM
Hello Kbanks,
I tried that option also.But still the same result.I am attaching the scripts (without LED blinking functionality to check for sleep)

Jheath
05-26-2009, 10:45 AM
Vijayaraj,
I believe the problem might be related to the type of module you are using.

The Synapse RF-Engine has keyboard interrupt capability on GPIOs 1,2,5,6,9 & 10. Modules manufactured by other vendors could have different KBI assignements. I would do a quick check of the documentation (appendix) related to your hardware for KBI pin placement.

As a reference: The evaluation kits come with two different types of board layout designed to provide access to GPIOs on the module. The Protoboard (http://www.synapse-wireless.com/index.php?mainID=3&subID=4&type=product&prodID=4)has a built-in button connected to GPIO 5. The bridge/end (http://www.synapse-wireless.com/index.php?mainID=3&subID=2&type=product&prodID=2) devices have built-in buttons connected to GPIO 1.

-Jonathan

vijayaraj
05-26-2009, 11:42 AM
Hello Jonathan,
Thanks for the suggestion.But I tried the external interrupt for the End Device which has button connected to GPIO1 in EK2500 kit.Even then the same result.

Thanks,

kbanks
05-26-2009, 12:32 PM
In your original post, you said that you were using an EK2500 kit. We took this to mean you were using standard (Synapse) RFE/REFT modules for your development. All of our posts and suggestions to date have been based on this assumption.

As I now understand it, you are using Panasonic PAN4555 based modules, not Synapse modules. (For those that haven't heard, Panasonic has licensed SNAP for some of their hardware).

Although both modules provide 19 GPIO pins, the underlying CPU pins used to implement those 19 GPIO are different in some cases.

Of particular interest to you is the fact that GPIOs 1, 2, and 5 are not connected to Key Board Interrupt (KBI) pins on the PAN4555 module.

This means those GPIO pins cannot be used to wake the processor from sleep.

You need to move your "wakeup" function to GPIO 6, 9, or 10, all of which are connected to KBI pins.

This difference between the Synapse RFEs and the PAN4555 modules was pointed out in Appendix A of the SNAP Reference Manual.

There are several other important differences, you need to review that appendix before proceeding further.

vijayaraj
05-26-2009, 01:20 PM
Hello Kbanks,
Thanks for the clarifications.If i am not wrong,I could see only the synapse RF Engine pin assignments in the SNAP reference manual.Not the difference Synapse RFEs and the PAN4555 modules.Can you please give the version of reference manual and details

Jheath
05-26-2009, 01:50 PM
Can you please give the version of reference manual and details

Attached is a copy of Appendix A (SNAP Reference Manual)

vijayaraj
05-26-2009, 01:54 PM
Thanks for the information :)