This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Implementing a sensor network with simpliciTI using AP as data hub

Other Parts Discussed in Thread: CC2500, MSP430FG4618, SIMPLICITI

Hello,

I am working on a sensors network where I use the on the MSP430FG4618 (I have the F4618 EVM) to store data in the End Device and send it to the Access Point. For the RF part I am using the CC2500 EVM.

I am filling out 16 addresses of the RAM memory (16 words therefore 32 bytes) with arbitrary data. I want to send a packet of information consistent the 32 bytes (16 words) from the End Device to the Access Point.  I understand that I should modify the function linkTo() in order to send the info but I haven't succeed on that. Any advise?

Now, once on the access point, how do you store the data you receive? I want to save the received data in the RAM memory. I know that the processMessage function is the one that handles the received info but still cannot get it to work.

I have some experience with the MSP430 but I am new with simpliciTI, I hope somebody can give me advise on this.

I really appreciate the help.

Efrain

  • Here is some code which does what I think you are looking for.  It replaces the project for the AP as data hub under the ez430 platform and also provides modified main files for the autoack version of the project.  You will want to copy the files in the appropriate directories into the same directories in your installation of simpliciti as this set of files only contains those files which needed to be changed.

    7888.SimpliciTI-IAR-1.1.1.zip

    The code implements a simple command driven interface via the back channel virtual com port on the ez430 devices.  You can control the whole system from a hyperterminal window or you can use the GUI package in the polling_pwms subdirectory.  If you want the source code for the GUI, let me know but its a bit big to post directly if you don't need it.

    You will program up each end device (up to 10) using the end device configuration for the ez430-CC2500 and make sure each device has a different address.  Then program up one ez430-CC2500 as an access point and attach this one to your computer.

    If you want to use hyperterminal, find the correct port by looking at the device manager and seeing which port is added when you unplug and re-plug the access point dongle.  Then open a connection using 9600 baud, 8 bit data, 1 stop bit, and no flow control.  Once the connection is open, type L^m^j where ^M is (ctrl + m) and ^j is (ctrl + j).  Note characters are case sensitive.  After typing this three character command, if all is working properly, you should get a loopback command response from the access point.  This proves the com port is working to the dongle.

    After you know the com port is working, turn on one end device at a time. you should get confirmation in the hyperterminal window that another link was established.  After you have setup your network with a number of end devices (1 is all you need but more shows the system better) type the command C^m^j and the access point should respond with the number of connected links.

    If you type the command Inn^m^j (a capital I as in Identify) where nn is the node number you wish to identify, i.e. 00 for node number zero, 01 for node 1, etc., within a couple of seconds of pressing the ^j you should see one of the LED's on the corresponding end device blink to identify it.

    If you now type the command Qnn^m^j, again nn is the node number, after a couple of seconds the node will respond with the value held in it's PWM value register.

    Finally, if you type the command Pnn:xxx^m^j where nn is the node number, and xxx is a three digit decimal number between 000 and 100 inclusive, you will set the PWM register on node nn to the value xxx.  Unfortunately, I haven't had the time to make the PWM code work properly so for now it merely holds the data in a variable on the end device.

    The reason for the delay's in operations is that the network is set up with the end devices as polling end devices.  This means they turn off thier radios and sleep for about 4 seconds.  Then when they wake up they querry the access point to see if there are any messages for it and if so it downloads them at that time and responds if necessary.

    One last demonstration is to press the button on one of the end devices.  You should see a response in the hyperterminal window indicating the state of the button.  Note that there is no delay here as the radio is awaken immediately as the button press represents an event to respond to.

    The radios don't actually sleep, the code merely turns off the radio so it appears to be sleeping.  This simplifies the code for the demonstration but everywhere in the code where a long delay is implemented is where you would actually put the system to sleep.

    If you install the GUI, you can manage all of this simply by clicking buttons and stuff.  Make sure the access point is plugged in before opening the com port.  The GUI will detect the correct com port automatically.  Each time a new node is linked into the network, a set of controls for that node will be displayed.

    Hope this is the type of code you were looking for,

    Jim Noxon

  • Hi Jim,

     

    Thank you for the answer. Give me a couple of days to go through it and I will let you know how it went.

     

    Have an excellent Sunday/

    Efrain

  • Hi again Jim,

    I have a couple of extra questios:

    Do you have a CCS version of this code?

    Is this project a modified version of the Wireless Sensor Monitor Using the eZ430-RF2500 described in the next app note?

    http://focus.ti.com/lit/an/slaa378d/slaa378d.pdf

     

    Thanks,

     

    Efrain

     

     

  • I have not created a CCS project using this code.  However, you should be able to easily modify the existing CCS version of SimpliciTI to accommodate the source files.  All you need to do is to replace the files in the applications directory of the CCS download of SimpliciTI, add in the extra files and update the configuration files to match those in the project I've given you.

    The code is a modified version of the AP_as_Data_Hub  sample application provided in the standard distribution of SimpliciTI (http://www.ti.com/simpliciti).  It has nothing to do with the Wireless Sensor Monitor demo code.

    Jim Noxon

  • OK. I was working on it and getting some linking errors, I should be able to solve them. I'll let you know how it goes.

     

    Efrain

  • The link errors are most likely due to not adding in the uart.c and uart_intfc.c files to the project.

    Jim Noxon

  • A function called SET_PWM_VALUE was giving me the problem. Since I am not using it I just commented it and it compiles now. I am modifying the code such that I can use it the way I need it.

     

  • After going to the code example that you sent me and checking the original AP as data hub I understand how to use simpliciTI to send the information from different End Devices.

    Now my question is about the data itself. Any signal can be described as y=f(t). When I sample information using the ADC12 module on the MSP430 I obtain signal value y, but in order to reconstruct the signal on the other end I also need the time information "t". Clearly y=f(t) comes from the ADC samples and I can send that to the AP and have "the right shape" but not with the correct timing info. Send the right shape and timing info would imply 2 data points, y and t, for each sample.I have though in many complicated ways to do this but it is getting very complex. Do you have any suggestion on how to send the signal and timing info to the AP?

  • Allow me to make some definitions first.

    Generaly, a lower case t is used for continuous time systems.  When moving to sampled systems, Ti is used as it represents the time of the ith sample.  This reason for detailing this semantic difference is to ease the mathematical representation a bit.  Note that Ti represents a sample period as in Ti = ti+1 ti.  Further simplification results if we make all the sample periods the same, i.e. T0 = T1 = T2 = ... = Ti.  Thus, all sample periods can be represented by the constant T0.  In this case, each sample time is then merely Ti = iT0.  In this case, the sample period wouldn't need to be sent with each ADC sample as the constant T0 would be known at compile time.

    In your system it sounds like you are using a non constant sample period thus your requirement to send the sample period with each sample.  In this case and from a code stand point, it would be easier to send the sample time of ti+1 as the actual sample period can be reconstructed from this stream of sample times as above.  Note that t0 = 0 in this case.

    Now for how to do it.  The suggested form would be to simply have a timer count from 0 to FFFF (or what ever value you choose) but a modulo 2 value can be easier when calculating the sample period.

    Next, when you sample the ADC, simply sample the timer value at the same time.  You shouldn't need to worry if the samples of the ADC and timer are not simultaneous as long as the latency between the two is constant, as in a couple of machine instructions of time.  You may want to disable interrupts while sampling the ADC and timer otherwise you may get some sample periods which include the latency of an interrupt being run.

    Once you have the sample of the ADC and timer, package them up and send them across the radio link.

    Now for the code on the far end radio. 

    void get_samples( void )
    {
      static uint16_t last_time_sample = 0;
      uint16_t time_sample;
      uint16_t sample_period;
      uint16_t adc_sample;

      // get samples from radio
      radio_recieve( &adc_sample, &time_sample );
      // calculate t(i+1)-t(i)
      sample_period = time_sample - last_time_sample;
      // save sample time history
      last_time_sample = time_sample;
      // output current sample and sample period
      plot( adc_sample, sample_period );

    }

    If you prefer, you could return the data in a structure instead of calling the plot function but you should get the idea.

    The subtraction works if the timer is allowed to count to its maximum value as the difference will always be calculated correctly from the modulo arithmetic of finite sized integers.  If you don't want your timer to count to maximum value then you just need to put a check in to determine if the timer overflowed by comparing it to the last sample time.

    Hope this is what you were looking for.

    Jim Noxon

  • Thank you for the definitions on your previous comment.

    What you are suggesting me is pretty much what I was thinking but in the way you explained it, doesn't sound that complicated. Since the ECG signal contains frequencies from 1Hz to 150Hz and the fastest transition occurs during the QRS complex (shown in the picture below)  to have "adaptable sampling" would allow power saving.

     

    Therefore the system is going to have an adaptive sampling mode and a static sampling mode. For the adaptive sampling mode I will base MY code on your suggestions.

    For the static sampling mode, from your comment "In this case, the sample period wouldn't need to be sent with each ADC sample as the constant T0 would be known at compile time." I understand that the value of T0 would be simply the time resulting from the respective arithmetical operation between the timer count value, the clock source (ACLK in this case) and the  the mode in which the timer is used. Therefore at the other end, the time space between sample is a known value and the signal can be easily reconstructed. Is this correct?

     

    Also, I was looking for a way to debug the wireless link between AP and an End Device at the same time using CCS, in order to verify that my code works as I expect. I found this post

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/41691.aspx

    and I will try to follow what is suggested on the video posted by Ki-Soo Lee on his second post.  Would that be the best way to debug the link or do you know a more effective way to d so?

     

    Regards,

     

    Efrain Gaxiola

  • I would say your interpretation of the static sampling mode is correct.

    The video by Ki is good information for setting up CCS to do multiple core/board debugging.  I would suggest setting a break point at the entrance to the code you call for transmitting data and also at the entrance to the receive ISR.  In this manner your debugging should go something like this

    1. Transmitting processor hits break point at transmit routine when it is ready to transmit data.
      1. verify data to send is correct
      2. step over this function call
      3. leave processor halted after this function call
    2. Receiving processor should hit break point in recieve ISR routine from 1.b. above.
      1. verify data received matches data which was sent
      2. step through code to validate proper consumption of data
      3. click the "GO" or "RUN" button to release the processor to run normally
    3. On the transmitting processor, click the "GO" or "RUN" button to release the processor to run normally
    4. Goto step 1

    The above procedure should get you through debugging the basics of your algorithm.  You may want to modify your ADC sample algorithm to simply provide data from an array of valid samples as the realtime aspect of sampling will have been thrown out due to halting of the processors.

    Once you are confident the data is being communicated properly and your code is handling the data appropriately, remove the break points and see what you get.

    Good luck,

    Jim Noxon

  • Hi again,

     

    I followed the instructions from the link I gave you before to modify the Target configuration and I have it as the picture show:

    Nevertheless, when I click on debug I get this error:

     

    Error initializing emulator:
    Only one MSP430 device can be accessed at a time per each CCS process. Please start another instance of CCS for accessing the second FET, or reconfigure your Target Configuration file.

    How do I start another instance of CCS? Is it just another Project in the same workspace? How can I debug the AP and ED projects then?

     

    Thanks,

     

    Efrain

  • Here is the image, I am sorry I didn't add it properly before.

     

     

    Efrain

  • This link discusses multiple debug sessions in CCS4

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/41691/147857.aspx#147857

    There is also a video showing how to set it up.

    I know it is for another processor family but the same operations should apply.

    Jim Noxon

  • I believe that link leads to the same post I was talking about in a previous comment. But I figured out how to debug the AP and the ED.

    Since English is not my first language I didn't understand what a "CCS instance" was, so I created a similar project on the same workspace and tried to do what was showed on the link we posted before. After going over that and looking for other posts I realized that for the case of the MSP430 you can't have more than one processor on the same target configuration. That is discussed on this post:

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/104982/370249.aspx#370249

    Then since I had to terminate the debug session if I tried to debug other project within the same workspace I tried launching another CCS (I realized that this happens to be another CCS instance) in other workspace. Nevertheless it wasn't detecting the other FET. Then what I did is to modify the Target Configuration on one of the two instances such that one used TI MSP430 USB2 as a connection while the other kept using the default TI MSP430 USB1 connection. Of course I added the MSP430FG4618 as the device for the modified Target Configuration. Now I am modifying the code and debugging the projects.

    So in summary, to debug two projects with CCS you need to launch two CCS instances with a different work space on each, and modify the Target Configuration such that the connection is not done by the same device.

    Regards,

    Efrain