Jump to content
43oh

CorB

Members
  • Content Count

    288
  • Joined

  • Last visited

  • Days Won

    5

Reputation Activity

  1. Like
    CorB reacted to pabigot in first look: BSP430   
    Having wrestled mspgcc mostly to a state of stability and feature-completeness, I've been moving back towards using the MSP430 for real application code. The next tool I needed was a board support environment that met my needs. I've got the first public release up at https://github.com/pabigot/bsp430 and thought people here might want to take a look. In the next month or two I'll be extending this with examples of much more complex features including full ChipCon radio support, the CC3000 WiFi module, and integration into FreeRTOS.
     
    Here's the blurb:
     
    BSP430 is a set of C language adaptation layers simplifying cross-MCU library and application development on Texas Instruments MSP430 microcontrollers. The target audience is experienced embedded systems developers who need full control over the microcontroller but are willing to trade a small amount of performance for improved component re-usability and rapid prototyping.
     
    For more details, the documentation is at http://pabigot.github.com/bsp430
  2. Like
    CorB reacted to drkm in Stellaris LaunchPad   
    I love the m3, but I have to use the C28x line for speed. I was really excited about the LM4F (with floating point accelerorator!!!)
     
    Now go and check attached image. Prepare for mind explosions...

  3. Like
    CorB reacted to xpg in Mailbox Notifier   
    The mailbox notifier is a simple system, which notifies about new mail in the physical mailbox. It consists of two parts: The transmitter and the receiver. The two components talk to each other using a 433MHz wireless protocol.
    The transmitter sits in the mailbox and detects if the mailbox





  4. Like
    CorB reacted to msptest6 in Difference Between C2000 Launchpad and Stellaris Launchpad   
    Good question! Lets see. Below is my attempt at this.
     

  5. Like
    CorB reacted to msptest6 in Real-Time Control - A C2000 Debugging Gem   
    A test to display a live temperature graph. The chip is pretty warm, so much so that when I place my finger on it, the temp. goes down - meaning my finger is acting as a heat sink. The temp value is the first value of the temperature array. Pretty cool.
     

  6. Like
    CorB reacted to TI_Trey in Problems in Example_F2802xLaunchPadDemo   
    CorB,
     
    Glad to hear things are working for you. By default I would recommend you keep all the switches in the up position during debugging. S4 really doesn't matter as it is just used to prevent contention on the serial lines should more than two devices be connected to the serial lines. S1controls how the board boots up. Basically if you are debugging you want all the switches up, if you are running standalone you want the switch on the right in the down position. There are other modes as well that can be read about in the BootROM users guide.
     
    Now on to the warnings:

    "../Example_F2802xLaunchPadDemo.c", line 373: warning: argument of type "int (*)(int, char *, unsigned int)" is incompatible with parameter of type "int (*)(int, const char *, unsigned int)" status = add_device("scia", _SSA, SCI_open, SCI_close, SCI_read, SCI_write, SCI_lseek, SCI_unlink, SCI_rename);
    This is a very minor warning. You can see the function wanted a char * and I passed it a const char *. 99.9% of the time this won't cause an issue, but it will depend on the function you are passing the messed up variable to.
     

    "../Example_F2802xLaunchPadDemo.c", line 280: warning: variable "fid" was set but never used volatile FILE *fid;
    This warning just means we saved a value in a variable but never did anything with it. Typically you'll get these when you've added variables for debugging purposes that aren't used else where in your application. These warnings may always be safely ignored.
     

    ../f2802x_common/cmd/F28027.cmd", line 117: warning: memory range not found: FLASHD. on page 0 .text : >> FLASHA | FLASHC | FLASHD. PAGE = 0
    This warning is due to a typo that snuck past me. There is a FlashD in the memory map, but in the linker file somehow a period accidentally got typed instead of a comma. If you change the line to read:

    .text : >> FLASHA | FLASHC | FLASHD, PAGE = 0
    you won't get this warning. I'm aware of this typo and it will be fixed in the next release.
     

    warning: entry-point symbol other than "_c_int00" specified: "code_start"
    All of TI's code gen tools really like your application to start with a symbol called _c_int00. We however supply a piece of code called CodeStartBranch which does some handy things like turn off the watchdog so its easier to debug. In our example applications we manually set the program entry point in the project properties to code_start. If anything other than _c_int00 is used you will get a warning like this. This warning can be safely ignored.
     
    Hope that helps!!!
  7. Like
    CorB reacted to msptest6 in Real-Time Control - A C2000 Debugging Gem   
    If you are not familiar with the C2000 series, you are going to love this. C2000 silicon has something known as real-time control. This allows you to watch variables in "real -time" as it changes in your controller in your watch window, through the JTAG. I put real-time in quotes as the update speed depends on your JTAG speed and the amout of data being transferred.
    I know this as I have worked with motor control alot and used the real-time feature to update FOC/current graphs in almost real time. This has been a god-send helping solve many problems.
     
    Anyway, enabling this is simple. Just follow the steps below:
    Compile your program. I'm using Example_2802xLEDBlink.c from ControlSuite in the C2000 Launchpad folder.
     
    Once compiled, press the "Debug" button.
     
    Next place the variable you want to check in the watch window. I used interruptCount++.
     
    Next click the real time button(clock with a pause sign). The button next to it gets selected automatically.This is ok.
     
    Now in the debug window, click the real time continuous refresh button above your watch window.
     
    Place play, or run your program. The variable should automatically update.

    Tips:
    - You can change the refresh rate like below.

     
    - There is something known as rude real time too, but I'm unable to find the setting. I'll update when I do.
    - You can do funky stuff with it like display graphs etc in real time.
  8. Like
    CorB reacted to infinityis in [S] ProtoPowerSwitch Boosterpack (formerly AC-powered Relay BoosterPack)   
    The new boards are in! Hopefully I can find some time to solder it up soon and verify the functionality. They were ordered from Iteadstudio, which was actually a better deal than Seeedstudio for this size board, plus it included 100% etest instead of 50%, and they threw in an extra board when they shipped them (final qty: 11). The build quality looks quite nice. The only problem I've seen so far is that I accidentally made a few of my vias too large so they didn't tent properly. Thus, one via doesn't meet HV clearance requirements so I may have to conformal coat that via.
     
    In the meantime I've started putting together some documentation describing the functionality, configuration options, etc. since there are so many different ways this thing can be put together (including using it as a basic Relay, SCR, and/or TRIAC board wherein the Launchpad itself is isolated from the mains)
     

  9. Like
    CorB reacted to SugarAddict in [Piccolo] Are MSP430 BoosterPacks compatible with C2000 BoosterPacks   
    Trey: page 12 of the TMS320F28027.pdf has a typo: "Enhanced PWM external synch pulse output" I think a synch pulse would be cool
     
    On a side note... I spent a bit making this spreadsheet so I could see things on one page if anyone else finds it handy.
     
    LPComparison.zip
  10. Like
    CorB reacted to msptest6 in [Piccolo] Are MSP430 BoosterPacks compatible with C2000 BoosterPacks   
    Most of the BPs were made before the C2000 Launchpad came out, so a little software work or hardware pin routing may be necessary.
    Also, good find on the page. This is the first time I'm seeing it.
  11. Like
    CorB reacted to larsie in Laser cut box for launchpad   
    I tested the acrylic with capacitative touch, and it worked right through the plastic, so bundling with a boosterpack could be quite cool.
  12. Like
    CorB got a reaction from bluehash in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Not thats not possible, so all the experimentation was done using trial-and-error approaches setting one variable at a time. For finding the best channel to receive the OOK data I used the buttons on the LCD boosterpack I am using.
     
    It should BTW be technically possible to create an application alike smartRF that controls the AIR boosterpack using UART commands or so send via a PC.
     
    Cor
  13. Like
    CorB reacted to larsie in Laser cut box for launchpad   
    So every cool platform needs a laser cut acrylic box (apparently). I
  14. Like
    CorB got a reaction from larsie in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    After another week of further experimentation I finally got the system running the way I want it. Its a bit of a multi-device design but it works fine.
     
    Current setup:
    - 3 TX3TH sensors (1 outside 2 inside) that transmit their data every minute at 433.92Mhz in On/Off Keying (OOK).
    - 1 AIR Boosterpack programmed as a relay to collect OOK data at 433 Mhz and transmit datapacks using SimpliciTI at 868 Mhz
    - 1 AIR Boosterpack programmed as 868Mhz SimpliciTI receiver connected via UART-serial to an Arduino
    - 1 Arduino with ethernetboard connected to THINGSPEAK and PUSHINGBOX, data is pushed out every minute
     
    Here's a plot of the temperature (left) and humidity(right) data I gathered the last 24hrs or so. My Lacrosse mainstation now has become more or less redundant and the tedious job of weekly downloading data from the mainstation via RS232 is also over.
     

     
     
    regards
    Cor
  15. Like
    CorB got a reaction from RobG in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    After another week of further experimentation I finally got the system running the way I want it. Its a bit of a multi-device design but it works fine.
     
    Current setup:
    - 3 TX3TH sensors (1 outside 2 inside) that transmit their data every minute at 433.92Mhz in On/Off Keying (OOK).
    - 1 AIR Boosterpack programmed as a relay to collect OOK data at 433 Mhz and transmit datapacks using SimpliciTI at 868 Mhz
    - 1 AIR Boosterpack programmed as 868Mhz SimpliciTI receiver connected via UART-serial to an Arduino
    - 1 Arduino with ethernetboard connected to THINGSPEAK and PUSHINGBOX, data is pushed out every minute
     
    Here's a plot of the temperature (left) and humidity(right) data I gathered the last 24hrs or so. My Lacrosse mainstation now has become more or less redundant and the tedious job of weekly downloading data from the mainstation via RS232 is also over.
     

     
     
    regards
    Cor
  16. Like
    CorB got a reaction from Automate in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    After another week of further experimentation I finally got the system running the way I want it. Its a bit of a multi-device design but it works fine.
     
    Current setup:
    - 3 TX3TH sensors (1 outside 2 inside) that transmit their data every minute at 433.92Mhz in On/Off Keying (OOK).
    - 1 AIR Boosterpack programmed as a relay to collect OOK data at 433 Mhz and transmit datapacks using SimpliciTI at 868 Mhz
    - 1 AIR Boosterpack programmed as 868Mhz SimpliciTI receiver connected via UART-serial to an Arduino
    - 1 Arduino with ethernetboard connected to THINGSPEAK and PUSHINGBOX, data is pushed out every minute
     
    Here's a plot of the temperature (left) and humidity(right) data I gathered the last 24hrs or so. My Lacrosse mainstation now has become more or less redundant and the tedious job of weekly downloading data from the mainstation via RS232 is also over.
     

     
     
    regards
    Cor
  17. Like
    CorB got a reaction from Nytblade in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Not thats not possible, so all the experimentation was done using trial-and-error approaches setting one variable at a time. For finding the best channel to receive the OOK data I used the buttons on the LCD boosterpack I am using.
     
    It should BTW be technically possible to create an application alike smartRF that controls the AIR boosterpack using UART commands or so send via a PC.
     
    Cor
  18. Like
    CorB got a reaction from Automate in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Update on the code I use.
     
    After a lot of experimentation (testing many different settings at different locations in the house) I now am using the settings as shown below in the code to receive the OOK signals. Especially the setting of AGCCTRL2 seems to be crucial. I initially tried to set AGCCTRL2 to get signals as strong as possible (using higher gains) but this gave problems. When I started to reduce the gain the signals became weaker but the signal quality was higher (I now receive signals at -105 dB). Additionally I have made the Bandwidth (MDMCFG4) smaller than I had it originally and that also helped signal quality. Reducing the bandwith further does still improve signal quality but the TX3TH sensors seem to be less stable in terms of the broadcast frequency and with a smaller bandwith you can more often loose the signal. The current setup allows me to read an outside mounted TX3TH from Lacrosse at 15meters or so (when I am inside the house behind a concrete wall) and 2 inside sensors at about 5 meters (havent tried to move them further away).
     
    regards
    Cor
     

    void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE // SET 432Mhz as base frequency TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x30); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync //Channel spacing is 25Khz TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0x00); // CHANNEL SPACING LSB //Receiver gain uses low gain TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0x40); // receiver gain // channel position (multiply with channel spacing to obtain frequency) TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 81); TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode }
  19. Like
    CorB got a reaction from Nytblade in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Update on the code I use.
     
    After a lot of experimentation (testing many different settings at different locations in the house) I now am using the settings as shown below in the code to receive the OOK signals. Especially the setting of AGCCTRL2 seems to be crucial. I initially tried to set AGCCTRL2 to get signals as strong as possible (using higher gains) but this gave problems. When I started to reduce the gain the signals became weaker but the signal quality was higher (I now receive signals at -105 dB). Additionally I have made the Bandwidth (MDMCFG4) smaller than I had it originally and that also helped signal quality. Reducing the bandwith further does still improve signal quality but the TX3TH sensors seem to be less stable in terms of the broadcast frequency and with a smaller bandwith you can more often loose the signal. The current setup allows me to read an outside mounted TX3TH from Lacrosse at 15meters or so (when I am inside the house behind a concrete wall) and 2 inside sensors at about 5 meters (havent tried to move them further away).
     
    regards
    Cor
     

    void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE // SET 432Mhz as base frequency TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x30); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync //Channel spacing is 25Khz TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0x00); // CHANNEL SPACING LSB //Receiver gain uses low gain TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0x40); // receiver gain // channel position (multiply with channel spacing to obtain frequency) TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 81); TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode }
  20. Like
    CorB got a reaction from bluehash in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Update on the code I use.
     
    After a lot of experimentation (testing many different settings at different locations in the house) I now am using the settings as shown below in the code to receive the OOK signals. Especially the setting of AGCCTRL2 seems to be crucial. I initially tried to set AGCCTRL2 to get signals as strong as possible (using higher gains) but this gave problems. When I started to reduce the gain the signals became weaker but the signal quality was higher (I now receive signals at -105 dB). Additionally I have made the Bandwidth (MDMCFG4) smaller than I had it originally and that also helped signal quality. Reducing the bandwith further does still improve signal quality but the TX3TH sensors seem to be less stable in terms of the broadcast frequency and with a smaller bandwith you can more often loose the signal. The current setup allows me to read an outside mounted TX3TH from Lacrosse at 15meters or so (when I am inside the house behind a concrete wall) and 2 inside sensors at about 5 meters (havent tried to move them further away).
     
    regards
    Cor
     

    void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE // SET 432Mhz as base frequency TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x30); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync //Channel spacing is 25Khz TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0x00); // CHANNEL SPACING LSB //Receiver gain uses low gain TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0x40); // receiver gain // channel position (multiply with channel spacing to obtain frequency) TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 81); TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode }
  21. Like
    CorB reacted to oPossum in MSP430G2553 ADC10   
    To ensure you have a contiguous block of integers, you have to declare an array and then get the address of it.
     

    #include void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT unsigned A[4]; // ADC readings ADC10CTL1 = INCH_4 | CONSEQ_1; // A4 + A3 + A2 + A1, single sequence ADC10CTL0 = ADC10SHT_2 | MSC | ADC10ON; while (ADC10CTL1 & BUSY); ADC10DTC1 = 0x04; // 4 conversions ADC10AE0 |= (BIT1 | BIT2 | BIT3 | BIT4); // ADC10 option select P1DIR |= (BIT0 | BIT6); // Set P1.0 + P1.6 to output while (1) { ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); ADC10SA = (unsigned)&A[0]; //RAM Address of ADC Data, must be reset every conversion ADC10CTL0 |= (ENC | ADC10SC); //Start ADC Conversion while (ADC10CTL1 & BUSY); //Wait while ADC is busy if (A[0] > 0x320) P1OUT |= BIT0; else if (A[0] < 0xC8) P1OUT |= BIT6; else if (A[1] > 0x320) P1OUT |= BIT0; else if (A[1] < 0xC8) P1OUT |= BIT6; else if (A[2] > 0x320) P1OUT |= BIT0; else if (A[2] < 0xC8) P1OUT |= BIT6; else if (A[3] > 0x320) P1OUT |= BIT0; else if (A[3] < 0xC8) P1OUT |= BIT6; else P1OUT &= ~(BIT0 | BIT6); _delay_cycles(100); //For Breakpoints } }
  22. Like
    CorB got a reaction from dacoffey in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Excuses for the long post !!
     
    After I found out that I could detect signals in the 433Mhz band using an AIR Boosterpack (See viewtopic.php?f=9&t=2944 AIR Boosterpack RF spectrum display) I wanted to display the data I was receiving on the 433 Mhz band.
    Ive got a Lacrosse temperature/humidity logger WS8610 that can read up to 3 external sensors and log the data. These sensors broadcast their data every minute or so.
     
    Since I have a logger and I have a display you might ask why do you want to read the data ? My motivation for this is simple, the datalogger can only capture data for about 1.5 weeks and then the oldest readings are overwritten and I need to connect the datalogger to an old PC (that still has a USB-DB9 connector) to be able to store the data. If I can read the data directly from the sensors I can hook them up in a system I allready have running with several other sensors (gas, electricityusage, inside temperature) and store the data on the internet. For those that are interested I am using Thingspeak to store my data.
     
    So last week I started to look at a way to decode the signals I saw coming in using my spectrum display. Luckily other people had allready done a lot of work on the protocol used by the sensors. The sensordata is send using On/Off keying (OOK).
    See http://ftp.f6fbb.org/domo/sensors/tx_signals.php and http:/ftp.f6fbb.org/domo/sensors/tx3_th.php
     
    After a few days of trial-and-error approach (thanks go to larsie for the feedback and ideas !) I actually was getting signals that could be the sensordata. To cut a long story short, using asynchronous CarrierSense detection on the AIR BOOSTERPACK and timing the length of the pulse coming in I can read the incoming data from several sensors. The software is definitely in its alpha stages. I can read one sensor properly but reading multiple sensors does give problems, if I set the RF registers to read the nearby sensor (3-4 meters away) the far away sensor (>10m) doesnt get picked up. When I set to register to read the far away, the nearby gets picked up but the data isnt as it should be anymore.
     
    Here's an image to show that I get results that are the same as my LaCrosse display shows (from left to right : MSP430 sandwich, Lacrosse display and a not active TX3TX sensor).
     

     
    The code below is based on the same GLCD and TI libraries as I used for my spectrum display project.
     
    regards
    CorB
     
     

    /* * This file is licensed under BSD. The simplicity code is originally copyright Texas Instruments, * but has been adapted by Lars Kristian Roland/Cor Berrevoets * the glcd code is by Lars Kristian Roland/Cor Berrevoets * the tx3th sensor information can be found at http://ftp.f6fbb.org/domo/sensors/tx3_th.php * the sensor first sends temperature information consisting of 11 blocks of 4 bits repeated once * the sensor secondly sends humidity information consisting of 11 blocks of 4 bits repeated once * block 0 is 0000 * block 1 is 1010 (preamble) * block 2 is sensortype 0=temperature E=humidity * block 3 is 4 bits sensorID * block 4 is 3 bits sensorID and another bit (unknown purpose) * block 5/6/7 is temperature in tenths degrees BCD +50 degrees * block 5/6/7 is humidity in tenths percent BCD (always ending at 0) * block 8 = block 6 * block9 = block 7 * block10 = CRC * */ //******************************************************************* // // G2553 // // ----------------- // | | // |VCC GND | // S1/GDO2 |P1.0 P2.6|-RF-GDO0 // S2 |P1.1 P2.7|-RF-CS // SW1 |P1.2 | // LED |P1.3 | // glcd-cs |P1.4 P1.7|<-------| glcd/RF-MISO //glcd/RF-CLK |P1.5 P1.6|------->| glcd/RF-SOMI // S3 |P2.0 P2.5| // S4 |P2.1 P2.4| // |P2.2 P2.3| // | | // ----------------- //******************************************************************* #include "ti/include.h" #include "../library/glcd_charset.c" #include "../library/glcd.c" unsigned long clockcnt=0,lastclock=0; unsigned long lastpulsecnt, pulsecnt=0,faultcount=0, pulselength=0; unsigned char bit; // bitcounter 0..3 unsigned char bitdata[4]={8,4,2,1}; // to create a nibble readout with MSB first coming in char pulseindx; // nibblecounter unsigned char pulsetrain[50],oldpulse[50]; // datapackage storage unsigned char line=4; // display of temperature datapackage int rssi; #define signal BIT2 void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x06); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0xe5); // x2E5=200Khz x1E5=100Khz x0E5=50Khz x000=25Khz, CHANNEL SPACING LSB TI_CC_SPIWriteReg(TI_CCxxx0_FOCCFG, 0x00); // no IF compensation for OOK TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0xc3); // receiver gain 0xAB A B TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 48); // change radio to channel 48 in 432Mhz band (50khz spacing) TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode } void main (void) { WDTCTL = WDT_MDLY_0_064; // WDT ~0.064ms interval timer IE1 |= WDTIE; // Enable WDT interrupt P1DIR |=signal; TI_CC_GDO0_PxIES &= ~TI_CC_GDO0_PIN; // Int on falling edge (end of pkt) TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // Clear flag for GDO0 TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN; // Enable interrupt on end of packet RF_init(); // SETUP ANAREN AIR RF __delay_cycles(50000); SPISetup(); // Initialize SPI Display __delay_cycles(100000); clear(); __delay_cycles(100000); //reset the pulsetrain indices and storage arrays for (pulseindx=0; pulseindx<49; pulseindx++) { pulsetrain[pulseindx]=0; oldpulse[pulseindx]=0; } pulsecnt=0; pulseindx=0; bit=0; lastpulsecnt=0; writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setup433MhzOOKreader(); __enable_interrupt(); // enable all interrupts while (1) // do for ever { if (pulsecnt>lastpulsecnt) // display data only of we have received a package { setcharmode(1); // switch to large characters if ((oldpulse[1]==0x0a) && (oldpulse[12]==0x0a)) { unsigned int temperature; unsigned int humidity; temperature=(oldpulse[5]-5)*100+oldpulse[6]*10+oldpulse[7]; writeInt(0,0,temperature,3); humidity=oldpulse[27]*10+oldpulse[28]; writeInt(48,0,humidity,3); lastpulsecnt=pulsecnt; } writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setcharmode(0); // switch to small characters unsigned char temp; char i,x; x=0; // show the 11 nibbles of the temperature part of the package for (i=0; i<11; i++) { temp = oldpulse[i]; temp += (temp > 9) ? 'A' - 10 : '0'; writeChar(x,line,temp); x=x+6; } writeInt(x+6,line,rssi,4); } } } #pragma vector = WDT_VECTOR // - Watchdog timer interrupt vector __interrupt void wdt_isr(void) // This interrupt will occur once per second { // clockcnt++; } #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) { // REALLY cheap debounce. // We can get away with this because we're edge triggering but reading the level. if(TI_CC_GDO0_PxIFG & TI_CC_GDO0_PIN) { pulselength=clockcnt-lastclock; lastclock=clockcnt; if (pulselength<30) {pulsetrain[pulseindx]|=bitdata[bit];} bit++; if (bit==4) {bit=0; pulseindx++;} if (pulseindx>43) // we got all 44 bits in { rssi=TI_CC_SPIReadStatus(TI_CCxxx0_RSSI); __delay_cycles(100); if(rssi < 128) // convert RSSI readout to dB { rssi = -((rssi/2) - 74); } else{ rssi = -(((rssi - 256)/2) - 74); } char j; for (j=0; j<45; j++) {oldpulse[j]=pulsetrain[j]; pulsetrain[j]=0; } //reset indices pulseindx=0; bit=0; //increment the line to display the datapackage line++; if (line>7) {line=4;} if (oldpulse[1]==0x0a) {pulsecnt++;} else {faultcount++; pulsecnt++;} // add a long delay after reading the 44th nibble, corrects possible mistakes also __delay_cycles(10000000); } TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // After pkt RX, this flag is set. } }
  23. Like
    CorB got a reaction from dacoffey in AIR Boosterpack RF spectrum display   
    Hi all,
     
    One of the things I wanted to build using the Anaren AIR boosterpack was a mini spectrum "analyzer" or spectrum display. During my holiday i found time to play around with both the AIR boosterpack and the LCD module Lars has produced.
     
    Although the AIR boosterpack was designed for 868/915 Mhz it seems the receiver inside (CC110L) is sensitive also in the 433Mhz region. The code I share with this mail allows the user (by changing a define) to switch between 3 frequencybands. Two buttons of the LCD package allow change of RX bandwidth and channelwidth.
     
    THe screenshot below shows a typical readout in the 433 Mhz band in a room where a Lacross TX3TH temperature/humidity sensor is sending data every minute using an OOK protocol (Request: if anybody knows how to receive/decode OOK using a CC110L please inform me). The display shows the low and high frequency in Mhz and shows the frequency with the highest readout (RSSI in dB) in kHz and as a blinking line in the graph.
     

     
    If you want to know more about this mini spectrum display or have other comments, feel free to share them.
     
    regards
    CorB
    spectrum.zip
    glcd.zip
  24. Like
    CorB got a reaction from Nytblade in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Excuses for the long post !!
     
    After I found out that I could detect signals in the 433Mhz band using an AIR Boosterpack (See viewtopic.php?f=9&t=2944 AIR Boosterpack RF spectrum display) I wanted to display the data I was receiving on the 433 Mhz band.
    Ive got a Lacrosse temperature/humidity logger WS8610 that can read up to 3 external sensors and log the data. These sensors broadcast their data every minute or so.
     
    Since I have a logger and I have a display you might ask why do you want to read the data ? My motivation for this is simple, the datalogger can only capture data for about 1.5 weeks and then the oldest readings are overwritten and I need to connect the datalogger to an old PC (that still has a USB-DB9 connector) to be able to store the data. If I can read the data directly from the sensors I can hook them up in a system I allready have running with several other sensors (gas, electricityusage, inside temperature) and store the data on the internet. For those that are interested I am using Thingspeak to store my data.
     
    So last week I started to look at a way to decode the signals I saw coming in using my spectrum display. Luckily other people had allready done a lot of work on the protocol used by the sensors. The sensordata is send using On/Off keying (OOK).
    See http://ftp.f6fbb.org/domo/sensors/tx_signals.php and http:/ftp.f6fbb.org/domo/sensors/tx3_th.php
     
    After a few days of trial-and-error approach (thanks go to larsie for the feedback and ideas !) I actually was getting signals that could be the sensordata. To cut a long story short, using asynchronous CarrierSense detection on the AIR BOOSTERPACK and timing the length of the pulse coming in I can read the incoming data from several sensors. The software is definitely in its alpha stages. I can read one sensor properly but reading multiple sensors does give problems, if I set the RF registers to read the nearby sensor (3-4 meters away) the far away sensor (>10m) doesnt get picked up. When I set to register to read the far away, the nearby gets picked up but the data isnt as it should be anymore.
     
    Here's an image to show that I get results that are the same as my LaCrosse display shows (from left to right : MSP430 sandwich, Lacrosse display and a not active TX3TX sensor).
     

     
    The code below is based on the same GLCD and TI libraries as I used for my spectrum display project.
     
    regards
    CorB
     
     

    /* * This file is licensed under BSD. The simplicity code is originally copyright Texas Instruments, * but has been adapted by Lars Kristian Roland/Cor Berrevoets * the glcd code is by Lars Kristian Roland/Cor Berrevoets * the tx3th sensor information can be found at http://ftp.f6fbb.org/domo/sensors/tx3_th.php * the sensor first sends temperature information consisting of 11 blocks of 4 bits repeated once * the sensor secondly sends humidity information consisting of 11 blocks of 4 bits repeated once * block 0 is 0000 * block 1 is 1010 (preamble) * block 2 is sensortype 0=temperature E=humidity * block 3 is 4 bits sensorID * block 4 is 3 bits sensorID and another bit (unknown purpose) * block 5/6/7 is temperature in tenths degrees BCD +50 degrees * block 5/6/7 is humidity in tenths percent BCD (always ending at 0) * block 8 = block 6 * block9 = block 7 * block10 = CRC * */ //******************************************************************* // // G2553 // // ----------------- // | | // |VCC GND | // S1/GDO2 |P1.0 P2.6|-RF-GDO0 // S2 |P1.1 P2.7|-RF-CS // SW1 |P1.2 | // LED |P1.3 | // glcd-cs |P1.4 P1.7|<-------| glcd/RF-MISO //glcd/RF-CLK |P1.5 P1.6|------->| glcd/RF-SOMI // S3 |P2.0 P2.5| // S4 |P2.1 P2.4| // |P2.2 P2.3| // | | // ----------------- //******************************************************************* #include "ti/include.h" #include "../library/glcd_charset.c" #include "../library/glcd.c" unsigned long clockcnt=0,lastclock=0; unsigned long lastpulsecnt, pulsecnt=0,faultcount=0, pulselength=0; unsigned char bit; // bitcounter 0..3 unsigned char bitdata[4]={8,4,2,1}; // to create a nibble readout with MSB first coming in char pulseindx; // nibblecounter unsigned char pulsetrain[50],oldpulse[50]; // datapackage storage unsigned char line=4; // display of temperature datapackage int rssi; #define signal BIT2 void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x06); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0xe5); // x2E5=200Khz x1E5=100Khz x0E5=50Khz x000=25Khz, CHANNEL SPACING LSB TI_CC_SPIWriteReg(TI_CCxxx0_FOCCFG, 0x00); // no IF compensation for OOK TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0xc3); // receiver gain 0xAB A B TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 48); // change radio to channel 48 in 432Mhz band (50khz spacing) TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode } void main (void) { WDTCTL = WDT_MDLY_0_064; // WDT ~0.064ms interval timer IE1 |= WDTIE; // Enable WDT interrupt P1DIR |=signal; TI_CC_GDO0_PxIES &= ~TI_CC_GDO0_PIN; // Int on falling edge (end of pkt) TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // Clear flag for GDO0 TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN; // Enable interrupt on end of packet RF_init(); // SETUP ANAREN AIR RF __delay_cycles(50000); SPISetup(); // Initialize SPI Display __delay_cycles(100000); clear(); __delay_cycles(100000); //reset the pulsetrain indices and storage arrays for (pulseindx=0; pulseindx<49; pulseindx++) { pulsetrain[pulseindx]=0; oldpulse[pulseindx]=0; } pulsecnt=0; pulseindx=0; bit=0; lastpulsecnt=0; writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setup433MhzOOKreader(); __enable_interrupt(); // enable all interrupts while (1) // do for ever { if (pulsecnt>lastpulsecnt) // display data only of we have received a package { setcharmode(1); // switch to large characters if ((oldpulse[1]==0x0a) && (oldpulse[12]==0x0a)) { unsigned int temperature; unsigned int humidity; temperature=(oldpulse[5]-5)*100+oldpulse[6]*10+oldpulse[7]; writeInt(0,0,temperature,3); humidity=oldpulse[27]*10+oldpulse[28]; writeInt(48,0,humidity,3); lastpulsecnt=pulsecnt; } writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setcharmode(0); // switch to small characters unsigned char temp; char i,x; x=0; // show the 11 nibbles of the temperature part of the package for (i=0; i<11; i++) { temp = oldpulse[i]; temp += (temp > 9) ? 'A' - 10 : '0'; writeChar(x,line,temp); x=x+6; } writeInt(x+6,line,rssi,4); } } } #pragma vector = WDT_VECTOR // - Watchdog timer interrupt vector __interrupt void wdt_isr(void) // This interrupt will occur once per second { // clockcnt++; } #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) { // REALLY cheap debounce. // We can get away with this because we're edge triggering but reading the level. if(TI_CC_GDO0_PxIFG & TI_CC_GDO0_PIN) { pulselength=clockcnt-lastclock; lastclock=clockcnt; if (pulselength<30) {pulsetrain[pulseindx]|=bitdata[bit];} bit++; if (bit==4) {bit=0; pulseindx++;} if (pulseindx>43) // we got all 44 bits in { rssi=TI_CC_SPIReadStatus(TI_CCxxx0_RSSI); __delay_cycles(100); if(rssi < 128) // convert RSSI readout to dB { rssi = -((rssi/2) - 74); } else{ rssi = -(((rssi - 256)/2) - 74); } char j; for (j=0; j<45; j++) {oldpulse[j]=pulsetrain[j]; pulsetrain[j]=0; } //reset indices pulseindx=0; bit=0; //increment the line to display the datapackage line++; if (line>7) {line=4;} if (oldpulse[1]==0x0a) {pulsecnt++;} else {faultcount++; pulsecnt++;} // add a long delay after reading the 44th nibble, corrects possible mistakes also __delay_cycles(10000000); } TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // After pkt RX, this flag is set. } }
  25. Like
    CorB got a reaction from bluehash in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Hi,
     
    Excuses for the long post !!
     
    After I found out that I could detect signals in the 433Mhz band using an AIR Boosterpack (See viewtopic.php?f=9&t=2944 AIR Boosterpack RF spectrum display) I wanted to display the data I was receiving on the 433 Mhz band.
    Ive got a Lacrosse temperature/humidity logger WS8610 that can read up to 3 external sensors and log the data. These sensors broadcast their data every minute or so.
     
    Since I have a logger and I have a display you might ask why do you want to read the data ? My motivation for this is simple, the datalogger can only capture data for about 1.5 weeks and then the oldest readings are overwritten and I need to connect the datalogger to an old PC (that still has a USB-DB9 connector) to be able to store the data. If I can read the data directly from the sensors I can hook them up in a system I allready have running with several other sensors (gas, electricityusage, inside temperature) and store the data on the internet. For those that are interested I am using Thingspeak to store my data.
     
    So last week I started to look at a way to decode the signals I saw coming in using my spectrum display. Luckily other people had allready done a lot of work on the protocol used by the sensors. The sensordata is send using On/Off keying (OOK).
    See http://ftp.f6fbb.org/domo/sensors/tx_signals.php and http:/ftp.f6fbb.org/domo/sensors/tx3_th.php
     
    After a few days of trial-and-error approach (thanks go to larsie for the feedback and ideas !) I actually was getting signals that could be the sensordata. To cut a long story short, using asynchronous CarrierSense detection on the AIR BOOSTERPACK and timing the length of the pulse coming in I can read the incoming data from several sensors. The software is definitely in its alpha stages. I can read one sensor properly but reading multiple sensors does give problems, if I set the RF registers to read the nearby sensor (3-4 meters away) the far away sensor (>10m) doesnt get picked up. When I set to register to read the far away, the nearby gets picked up but the data isnt as it should be anymore.
     
    Here's an image to show that I get results that are the same as my LaCrosse display shows (from left to right : MSP430 sandwich, Lacrosse display and a not active TX3TX sensor).
     

     
    The code below is based on the same GLCD and TI libraries as I used for my spectrum display project.
     
    regards
    CorB
     
     

    /* * This file is licensed under BSD. The simplicity code is originally copyright Texas Instruments, * but has been adapted by Lars Kristian Roland/Cor Berrevoets * the glcd code is by Lars Kristian Roland/Cor Berrevoets * the tx3th sensor information can be found at http://ftp.f6fbb.org/domo/sensors/tx3_th.php * the sensor first sends temperature information consisting of 11 blocks of 4 bits repeated once * the sensor secondly sends humidity information consisting of 11 blocks of 4 bits repeated once * block 0 is 0000 * block 1 is 1010 (preamble) * block 2 is sensortype 0=temperature E=humidity * block 3 is 4 bits sensorID * block 4 is 3 bits sensorID and another bit (unknown purpose) * block 5/6/7 is temperature in tenths degrees BCD +50 degrees * block 5/6/7 is humidity in tenths percent BCD (always ending at 0) * block 8 = block 6 * block9 = block 7 * block10 = CRC * */ //******************************************************************* // // G2553 // // ----------------- // | | // |VCC GND | // S1/GDO2 |P1.0 P2.6|-RF-GDO0 // S2 |P1.1 P2.7|-RF-CS // SW1 |P1.2 | // LED |P1.3 | // glcd-cs |P1.4 P1.7|<-------| glcd/RF-MISO //glcd/RF-CLK |P1.5 P1.6|------->| glcd/RF-SOMI // S3 |P2.0 P2.5| // S4 |P2.1 P2.4| // |P2.2 P2.3| // | | // ----------------- //******************************************************************* #include "ti/include.h" #include "../library/glcd_charset.c" #include "../library/glcd.c" unsigned long clockcnt=0,lastclock=0; unsigned long lastpulsecnt, pulsecnt=0,faultcount=0, pulselength=0; unsigned char bit; // bitcounter 0..3 unsigned char bitdata[4]={8,4,2,1}; // to create a nibble readout with MSB first coming in char pulseindx; // nibblecounter unsigned char pulsetrain[50],oldpulse[50]; // datapackage storage unsigned char line=4; // display of temperature datapackage int rssi; #define signal BIT2 void setup433MhzOOKreader() { TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x00); //Freq control word, mid byte. TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0x00); //Freq control word, low byte. TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x06); // RX bandwidth and datarate MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x37); // datarate LSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x00); // no preamble/sync TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x00); // CHANNEL SPACING and channelspacing MSB TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0xe5); // x2E5=200Khz x1E5=100Khz x0E5=50Khz x000=25Khz, CHANNEL SPACING LSB TI_CC_SPIWriteReg(TI_CCxxx0_FOCCFG, 0x00); // no IF compensation for OOK TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0xc3); // receiver gain 0xAB A B TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 48); // change radio to channel 48 in 432Mhz band (50khz spacing) TI_CC_SPIStrobe(TI_CCxxx0_SRX); // goto receivermode } void main (void) { WDTCTL = WDT_MDLY_0_064; // WDT ~0.064ms interval timer IE1 |= WDTIE; // Enable WDT interrupt P1DIR |=signal; TI_CC_GDO0_PxIES &= ~TI_CC_GDO0_PIN; // Int on falling edge (end of pkt) TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // Clear flag for GDO0 TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN; // Enable interrupt on end of packet RF_init(); // SETUP ANAREN AIR RF __delay_cycles(50000); SPISetup(); // Initialize SPI Display __delay_cycles(100000); clear(); __delay_cycles(100000); //reset the pulsetrain indices and storage arrays for (pulseindx=0; pulseindx<49; pulseindx++) { pulsetrain[pulseindx]=0; oldpulse[pulseindx]=0; } pulsecnt=0; pulseindx=0; bit=0; lastpulsecnt=0; writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setup433MhzOOKreader(); __enable_interrupt(); // enable all interrupts while (1) // do for ever { if (pulsecnt>lastpulsecnt) // display data only of we have received a package { setcharmode(1); // switch to large characters if ((oldpulse[1]==0x0a) && (oldpulse[12]==0x0a)) { unsigned int temperature; unsigned int humidity; temperature=(oldpulse[5]-5)*100+oldpulse[6]*10+oldpulse[7]; writeInt(0,0,temperature,3); humidity=oldpulse[27]*10+oldpulse[28]; writeInt(48,0,humidity,3); lastpulsecnt=pulsecnt; } writeInt(0,2,faultcount,3); // display faults writeInt(48,2,pulsecnt,3); // display how many packages have been read setcharmode(0); // switch to small characters unsigned char temp; char i,x; x=0; // show the 11 nibbles of the temperature part of the package for (i=0; i<11; i++) { temp = oldpulse[i]; temp += (temp > 9) ? 'A' - 10 : '0'; writeChar(x,line,temp); x=x+6; } writeInt(x+6,line,rssi,4); } } } #pragma vector = WDT_VECTOR // - Watchdog timer interrupt vector __interrupt void wdt_isr(void) // This interrupt will occur once per second { // clockcnt++; } #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) { // REALLY cheap debounce. // We can get away with this because we're edge triggering but reading the level. if(TI_CC_GDO0_PxIFG & TI_CC_GDO0_PIN) { pulselength=clockcnt-lastclock; lastclock=clockcnt; if (pulselength<30) {pulsetrain[pulseindx]|=bitdata[bit];} bit++; if (bit==4) {bit=0; pulseindx++;} if (pulseindx>43) // we got all 44 bits in { rssi=TI_CC_SPIReadStatus(TI_CCxxx0_RSSI); __delay_cycles(100); if(rssi < 128) // convert RSSI readout to dB { rssi = -((rssi/2) - 74); } else{ rssi = -(((rssi - 256)/2) - 74); } char j; for (j=0; j<45; j++) {oldpulse[j]=pulsetrain[j]; pulsetrain[j]=0; } //reset indices pulseindx=0; bit=0; //increment the line to display the datapackage line++; if (line>7) {line=4;} if (oldpulse[1]==0x0a) {pulsecnt++;} else {faultcount++; pulsecnt++;} // add a long delay after reading the 44th nibble, corrects possible mistakes also __delay_cycles(10000000); } TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // After pkt RX, this flag is set. } }
×
×
  • Create New...