Fmilburn

Members
  • Content count

    541
  • Joined

  • Last visited

  • Days Won

    65

Everything posted by Fmilburn

  1. Nick Gammon published an interesting post on using SPI on 16 MHz Arduinos to run WS2812 LEDs (aka neopixels) at: http://gammon.com.au/forum/?id=13357. He also provides a link with a lot of information about the NRZ protocol used by the WS2812 and tolerances: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/. The tolerances are actually quite a bit looser than what I previously believed. So, I set out to do something similar with Energia and LaunchPads running at different speeds. Spoiler alert: It works. The previously linked articles provide all the background so minimal information is repeated here. NRZ is a one wire protocol that transfers information to the LEDs by varying the length of the signal when high. A longer pulse is used for a 1, and a shorter one for a 0. The timing, with tolerances, is shown in the figure below. The length between pulses cannot exceed about 5 us and most everything else is pretty loose. The protocol is implemented using SPI which I find pretty clever. A byte is sent out with the SPI module with the proper length to represent the desired bit for the protocol. The following must be determined and set to do this: Set proper SPI clock speed using SPI.setClockDivider() in Energia Determine the proper byte to send by SPI.transfer() in Energia to represent a 0 or 1 bit For example, using the MSP430F5529: Clock speed is 25.6 MHz Setting the SPI clock divider to 4 gives a SPI clock of 6.4 MHz and since the SPI block executes in one cycle (Arduino executes in 2), each bit in the byte is equivalent to 156.25 ns. Therefore, to send a pulse indicating a "1", a byte equal to 0b1111000 could be used which gives 4x156.25 = 625 ns. This is in the acceptable range of 550 to 850 ns. Similarly, for a 0 an acceptable byte would be 0b11000000 or 312.5 ns. A similar process can be used to determine acceptable values for the MSP430G2553. The sketch below is a simplification of the library presented by Nick which and includes the modifications described above to run on both the G2553 and F5529. The preprocessor is used to set appropriate values for the clock divider and long and short bytes. The functions are very nearly the same as posted by Nick. Note that interrupts must be disabled before sending data and then reenabled manually after. /* * WS2812 display using SPI on various TI LaunchPads with Energia * * Connections: * LaunchPad LED Strip * --------- --------- * 3V3 5VDC * Pin 15 (MOSI) DIN * GND GND * * How to use: * ledsetup (); - Get ready to send. * Call once at the beginning of the program. * sendPixel (r, g, ; - Send a single pixel to the string. * Call this once for each pixel in a frame. * Each colour is in the range 0 to 255. Turn off * interrupts before use and turn on after all pixels * have been programmed. * show (); - Latch the recently sent pixels onto the LEDs . * Call once per frame. * showColor (count, r, g, ; - Set the entire string of count Neopixels * to this one colour. Turn off interrupts before use * and remember to turn on afterwards. * * Derived from NeoPixel display library by Nick Gammon * https://github.com/nickgammon/NeoPixels_SPI * With ideas from: * http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ * Released for public use under the Creative Commons Attribution 3.0 Australia License * http://creativecommons.org/licenses/by/3.0/au/ * * F Milburn November 2016 * Tested with Energia V17 and WS2812 8 pixel strip on launchpads shown below. */ #include <SPI.h> #if defined(__MSP430G2553) #define SPIDIV SPI_CLOCK_DIV2 // 16 MHz/2 gives 125 ns for each on bit in byte #define SPILONG 0b11111100 // 750 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11100000 // 375 ns (acceptable "on" range 200 to 500 ns) #elif defined(__MSP430F5529) #define SPIDIV SPI_CLOCK_DIV4 // 25.6 MHz/4 gives 156.25 ns for each on bit in byte #define SPILONG 0b11110000 // 625 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11000000 // 312.5 ns (acceptable "on" range 200 to 500 ns) #else #error This microcontroller is not supported #endif const unsigned int PIXELS = 8; // Pixels in the strip void setup (){ ledsetup(); } void loop (){ // Show a solid color across the strip noInterrupts(); // no interrupts while sending data showColor (PIXELS, 0xBB, 0x22, 0x22); // single color on entire strip interrupts(); // interrupts are OK now delay(1000); // hold it for a second // Show a different color on every pixel noInterrupts(); // no interrupts while sending data sendPixel(0xBB, 0x00, 0x00); // red sendPixel(0x00, 0xBB, 0x00); // green sendPixel(0x00, 0x00, 0xBB); // blue sendPixel(0xBB, 0xBB, 0xBB); // white sendPixel(0xBB, 0x22, 0x22); // pinkish sendPixel(0x22, 0xBB, 0x22); // light green sendPixel(0x22, 0x22, 0xBB); // purplish blue sendPixel(0x00, 0x00, 0x00); // pixel off interrupts(); // interrupts are OK now delay(1000); // hold it for a second } // Sends one byte to the LED strip by SPI. void sendByte (unsigned char { for (unsigned char bit = 0; bit < 8; bit++){ if (b & 0x80) // is high-order bit set? SPI.transfer (SPILONG); // long on bit (~700 ns) defined for each clock speed else SPI.transfer (SPISHORT); // short on bit (~350 ns) defined for each clock speed b <<= 1; // shift next bit into high-order position } // end of for each bit } // end of sendByte // Set up SPI void ledsetup(){ SPI.begin (); SPI.setClockDivider (SPIDIV); // defined for each clock speed SPI.setBitOrder (MSBFIRST); SPI.setDataMode (SPI_MODE1); // MOSI normally low. show (); // in case MOSI went high, latch in whatever-we-sent sendPixel (0, 0, 0); // now change back to black show (); // and latch that } // end of ledsetup // Send a single pixel worth of information. Turn interrupts off while using. void sendPixel (unsigned char r, unsigned char g, unsigned char { sendByte (g); // NeoPixel wants colors in green-then-red-then-blue order sendByte (r); sendByte (; } // end of sendPixel // Wait long enough without sending any bits to allow the pixels to latch and // display the last sent frame void show(){ delayMicroseconds (9); } // end of show // Display a single color on the whole string. Turn interrupts off while using. void showColor (unsigned int count, unsigned char r , unsigned char g , unsigned char { noInterrupts (); for (unsigned int pixel = 0; pixel < count; pixel++) sendPixel (r, g, ; interrupts (); show (); // latch the colours } // end of showColor The timing, when checked on a logic analyzer, checks out with the calculations above (hooray for math). The "gaps" between pulses are within tolerance and largely set by code overhead as well as the byte being sent. And here it is showing the strip lit up in one color. I tried this on several other LaunchPads I had handy and here is a summary: FR6989 - I had never noticed, but Energia defaults to 8 MHz. Doing the math, there isn't a good match to the WS2812 requirements without changing processor speed (which I did not try). MSP432 - there was behavior I couldn't explain, probably due to RTOS and I didn't pursue this for long. In summary, the method works although I did limited experimentation. It would be even easier to implement outside of Energia with full access to clocks. It was an interesting exercise but alternative methods have been posted here on 43oh with tuned assembler and having used those successfully in the past, I will probably continue to preferentially use them in the future.
  2. Mine is Rev 1.6 but I should point out that RX,TX only ceased working when I accidently applied 5 volts to a pin - it worked fine before that. I have several F5529 LaunchPads and all were working on receipt Why use a F5529? The LaunchPad itself Costs $3 more but it is faster, has more memory, more and better peripherals (eg faster UART and higher resolution ADC), has USB, etc. It is easy to use if you are familiar with the G2553 and need the features.
  3. A while back I damaged two pins on this board and dutifully marked it on the back. Unfortunately it was only visible from the back. Some time later I picked it up and was trying to use it unsuccessfully. After tearing my hair out for a while I eventually turned it over and noticed the markings. Now it is marked front and back.
  4. PUSH is not a variable in the example / library that I suggested above so you must not be following the suggestion. In your first post it is not defined. It needs something like #define PUSH xxx where xxx is a pin number / designation. Doing a search for "DHT does not name a type" on the internet will give multiple hits and solutions to the problem so you apparently did not do the search as suggested. The library is probably installed incorrectly.
  5. As stated above, I tried the library that I linked above with a TM4C123 / DHT22 the same day I made the post and it worked. Use the example code that comes with the library. I was probably using Energia V17. Do a search with google with the error message text if you want to understand what it means.
  6. @Rickta59 I would not have caught that It works for me in V17 but not in V18. When I move it in V18, it works. What is happening?
  7. @energia I just tried compiling the nRF24L01 library in V18 and got the following error: In file included from C:\Users\Frank\Documents\Energia\MSP-EXP430F5529\Enrf24_RXdemo\Enrf24_RXdemo.ino:16:0: C:\Users\Frank\Documents\Energia\libraries\Enrf24/Enrf24.h:32:17: fatal error: SPI.h: No such file or directory compilation terminated. exit status 1 Error compiling for board MSP-EXP430G2553LP. @ghjkl67 You should not have to add SPI. Try using Energia V17 as I suggested above. You will find it here under previous releases: http://energia.nu/download/ Energia V18 still seems to have some bugs. I just flashed the sample code on two G2553s with nRF24L01s using Energia V17 and they are working fine. EDIT: I would remove the old versions of Energia before loading a new V17.
  8. How do you know it works as a receiver if you don't have anything working as a transmitter - what are you receiving without a transmission? Have you gone back and double checked that one of my suggestions isn't the cause? I can assure you that the library works when connected properly with the nRF24L01+ modules I have and a G2553 LaunchPad. The datasheet for the nRF24L01+ has all the details and can be found with a google search - it uses SPI. SPI keeps the chip select pin high until it is ready to transmit and then pulls it low. It then returns to high following transmission. The code for the library is in Enrf24.cpp. Look inside at the code, e.g. void Enrf24::_writeReg(uint8_t addr, uint8_t val) { digitalWrite(_csnPin, LOW); rf_status = SPI.transfer(RF24_W_REGISTER | addr); SPI.transfer(val); digitalWrite(_csnPin, HIGH); } It pulls it low before transmitting then returns to high. One more suggestion - if you do a search on the internet you will find various people have found this helps: https://forum.arduino.cc/index.php?topic=376068.0 I include a decoupling capacitor in my designs and normally power the radio from a battery. Nonetheless, I have also had success powering off of the LaunchPad.
  9. I have used this library with both custom MSP430G2553 boards and the LaunchPad. Hardware setup is the same whether receiver or transmitter. Among the possible problems and solutions are the following: Bad nRF24 - the very first one I bought was bad damaged pin on MSP430 - don't apply 5V to a pin - this is a 3V3 device nRF24 wired wrong or wrong pin in software - easy to do poor transmission between modules - too far apart, object in between, or even too close together. modules set on different channel or other incompatibility in way software is set up In general though, I have found the library easy to use and reliable. I suggest you concentrate on getting the examples working first without any modification. I haven't tried it with Energia V18, you might try Energia V17. The following are the pins I normally use: nRF pin pin# Std color F5529LP pin G2553 pin ------- ---- --------- ----------- --------- Vcc 1 Red 3V3 3V3 GND 20 Black GND GND CSN 9 Yellow P4.2 P2_1 CE 8 Green P2.7 P2_0 MOSI 15 White P3.0 P1_7 SCK 7 Orange P3.2 P1_5 IRQ 10 Brown P4.1 P2_2 MISO 14 Purple P3.1 P1_6 I use the same wire color every time to ease checking that the connection is correct. If CE is not going high then try setting up a simple pin toggling program (e.g. the "hello world" pin wiggling and check with multimeter) to see if it works without the library. This will tell you if the CE pin on the MSP430 has been damaged. If so, changing to a different pin will fix it until you get a new $2 chip. EDIT: Some multimeters can be quite slow to update. When toggling pins to see if they are reaching a full on state, keep the toggling frequency to 1 Hz so the meter can keep up. For monitoring an application like the one above an oscilloscope or logic analyzer is a better tool.
  10. You haven't provided enough information to get help.... Most importantly you have not stated what about the code is not working. Is it failing to compile? Is it giving bad results? Is it failing to print? You haven't stated which library you are using, etc... So, anyone attempting to answer your problem would just be guessing. Try using the Adafruit library without changing anything and have it print directly to the serial monitor: https://github.com/adafruit/DHT-sensor-library Use pin 2 (PB5) on the LaunchPad. I just tried it on my TM4C123 and it worked. Once that is working, try adding in the code for the LCD.
  11. Texas Instruments has standard shipping for $3.14 and 10% off selected tools through March 19th: http://www.ti.com/lsds/ti/store/march-ti-store-pi-week-promotion.page?HQS=ecm-tistore-promo-piweek17-bti-lp-null-wwe
  12. I'm attaching a link to github with Energia code examples for various sensors. I started this as a place to put examples for students in a course I was helping to develop for middle and high school level students using the MSP430F5529. Unfortunately the course was not held but I'm putting them out there in the hope they might help someone. Where the code has been tested with other LaunchPads I've noted it. Here it is: https://github.com/fmilburn3?tab=repositories You won't find anything sophisticated but many are at least somewhat unique in that I couldn't find an example for that sensor tailored specifically for the F5529, or I wanted to better document it for beginners. Essentially all are variants of work done by others, including work on 43oh, and I hope I've recognized the contribution in the code. There is a wiki associated with some that has the schematic and photographs. There is some other example code that is almost complete - e.g. using small DC motors and servos and I might add them. Here is a list of sensors and devices currently out there: CNY70 - used as a proximity switch CNY70 - used as a tachometer MCP41010 - digital pot HC-SR04 - distance sensor 3 watt high intensity LED MAX4466 -sound level I2C LCD (4x20) and (2x16) HC-SR501 - PIR movement detection SW-180xxP - vibration sensor Joystick PFatFs - compiles and runs on the F5529 Hall effect rainfall sensor TMP36 - temperature Sharp GPf1S53VJ000F - photo interrupter Using low power modes (LPM) in Energia TCS3200 Color Sensor using MSP432 *** added 8/8/15 DS1307 Real Time Clock (RTC) Module *** added 8/9/15 INA125P Instrumentation Amplifier *** added 10/9/15 MCP3008 ADC *** added 10/12/15 TLC5615 DAC *** added 11/30/15 dAISy MarineTraffic shore station w/ CC3200 ** added 12/16/15 AD9850 Frequency Generator ** added 1/20/16 FFT ** added 1/20/16 Rotary encoder ** added 1/23/16 W5500 Ethernet ** added 3/25/16 MSP430G2955 pins_energia.h ** added 3/25/16 DriverLib examples for F5529 ** added 8/16 Infrared Transmission ** added 12/16 WS2812 LEDs using SPI ** added 12/16 Battery measurement ** added 1/17 Finite State Machine - alarm system ** added 2/6/17 Using RTC module with Energia - F5529 ** added 2/24/17
  13. Hi iKlepto and welcome to 43oh... You can get jumpers M-M, M-F, F-F. For example.... https://www.addicore.com/Jumpers-and-Cables-s/1837.htm and many other places
  14. Hi @jBrizzle and welcome to 43oh... Maybe use a little module? Depending on your needs in terms of recording length and number of recordings that might work. I have used these although not from this vendor: https://www.amazon.com/Sound-Voice-Recording-Playback-module/dp/B018Q6TAEQ/ref=sr_1_2?ie=UTF8&qid=1489447073&sr=8-2&keywords=isd1820 They are cheap and work for a single recording but the amplification and quality isn't great. They can be controlled with a microcontroller. Maybe this: http://processors.wiki.ti.com/index.php/Audio_Capacitive_Touch_BoosterPack_Hardware I don't have experience with it but it looks interesting. I usually have a look at what Sparkfun and Adafruit are doing as well, even if I decide to make it myself.
  15. You appear to have taken on a project which is beyond your current capabilities. If you are a student, consider going to your professor/instructor for help or getting a simpler project. There are too many problems with your code as it stands to offer help in this forum - at least for me to offer help.
  16. Hi @@devdibyo and welcome to 43oh Try using the hardware, i.e. Serial1 as described here: http://energia.nu/reference/serial/ Take out the following: #include <SoftwareSerial.h> SoftwareSerial mySerial(P3_4, P3_3); Replace all instances of mySerial with Serial1.
  17. Hi @@osmanfish and welcome to 43oh, Irritating isn't it? It can be caused by several things. It can happen with the MSP430G2 and Energia if you are using serial print and close the serial monitor down while the sketch is printing. This does not seem to happen with other LaunchPads. Try unplugging the LaunchPad at the computer and then plug it back in. You may have to try uploading one or more times to get it working again. Also, avoid shutting down the serial window. Flash (upload) the target chip without shutting the serial monitor. If this does not seem to be your problem then google "Could not find MSP-FET430UIF on specified COM port (error = 57)" and you will find a number of other possible causes. Look on the TI e2e site.
  18. Hi @@SheldonMaciel, I don't have a working CC3200, but I do have a CC3100. I tried it just now with a F5529 using Energia V18 and the SimpleWebServerWifi example - it worked fine. You can try the following: make sure the jumper is in place as shown on the pin map for Energia revert back to the former version of Energia and/or CCS and try what worked before
  19. I suppose this is asking for quite a bit . But for those who really are interested in learning and getting a response to questions the following is a good link that also applies here: https://e2e.ti.com/group/helpcentral/b/weblog/archive/2015/07/17/5-tips-for-getting-quick-help-on-e2e It might be this can only be accessed if you are a member of e2e - not sure.
  20. I modified the TI DriverLib example for the RTC_A on the F5529 to demonstrate the same thing as the Energia library for my own educational purposes and placed it here: https://github.com/fmilburn3/MSP430F5529_driverlib_examples/blob/master/11A_RTC_A_calendar_mode
  21. I modified the code in the link above a bit and wrote a new example to demonstrate retrieval of the date and time as well as a few other features. It was not extensively tested. To use, post all of the files into a folder called RTC_F5529 where Energia can reach it. It is posted here: https://github.com/fmilburn3/RTC_F5529 Real credit for the work belongs to the original author.
  22. Have a look at this post: http://forum.43oh.com/topic/5421-energia-library-rtc-a/ I haven't used it in a project, but the post states that it runs with the F5529. It is not clear what your final objective is and whether you are trying any of this code yourself - try to get it working yourself first. If you have specific problems then post your objective, the code and the issue / error message you are getting. The original author may be willing to help and I will help as time permits. I may try running it myself this evening.
  23. Hi @@Neetee, Don't double post - it is bad etiquette. Your original post was not ignored and your lack of coding skill won't cause others to drop what they are doing and code it for you.
  24. I seem to remember someone posting a RTC example for the F5529 in Energia on 43oh a while back. In any event, as Terje says, the F5529 has a RTC module and there is driverlib support which can also be included in Energia. See these examples, one of which has the RTC module: https://github.com/fmilburn3/MSP430F5529_driverlib_examples The advantage of an external clock like the one Terje linked to is that they have a coin cell. Arduino code is usually easily ported. For that matter, MSP430 code like that linked by chicken is pretty easy to port between variants.
  25. Yes, of course. When you ask for advice, always specify the compiler/version you are using as well as the LaunchPad. Also, describe or post a photo of the circuit where it makes sense. Fully describe the problem and where possible give sufficient information for others to duplicate the problem. There is a button below posts in 43oh where you can thank others when you get help. The following was done in Energia V17. First, set up a source for Serial1. I used a F5529. TX for Serial1 is on pin 4. Here is the code, it outputs the 255 characters on one line and then starts over: void setup() { Serial1.begin(9600); } void loop() { int i; for(i=0; i<255; i++){ Serial1.write(i); delay(100); } } Second, set up a receiver, in this case a FR5969. RX for Serial1 is on pin3 and it is attached to pin 4 (TX) on the F5529. I am powering both LaunchPads off of the FR5969. Be sure to place a ground wire between the two LaunchPads. Here is the code for the receiver: void setup() { // initialize both serial ports: Serial.begin(9600); Serial.println("Started..."); Serial1.begin(9600); } void loop() { if (Serial1.available()) { int inByte = Serial1.read(); Serial.write(inByte); } } Run and the output will look something like this....