Jump to content

MORA99

Members
  • Content Count

    42
  • Joined

  • Last visited

Everything posted by MORA99

  1. This is a Websocket client library written mostly in highlevel c(++) to make it easyier to take in. It was tested on a CC3200 and earlier on a TM4C1294 but I think it should work on anything that provides the WifiClient/EthernetClient interface, and has decent amounts of RAM. Current code is a bit rough, it contains debug prints and I have not made much optimization work with it, especially concerning long strings where it just allocates up to 64kbyte of ram, but hopefully the user has some control over what is returned and can keep it short(ish). It does not support frames over 65kbyte nor binary data at the moment, but its not too hard to implement if needed. At the moment there is only 1 callback, when data is recieved, more callbacks could be added for connect, disconnect, ping, pong, etc. Well work in progress Like my dht lib the source code is maintained on github and my part of the code is released to public domain. The zip includes sha1 and base64 code that I didnt write, links to their home is included in top of WebSocketClient files. WebSocketClient.zip
  2. A library for reading dht sensors (temperature and humidity). Since dht sensors are pretty slow, I have used highlevel functions in the lib, there should be plenty of cycles even at 1MHz, but I have only tested it on the CC3200 sofar. Easy example, other functions are available for getting the raw values instead of float. if (dht::readFloatData(2, &temperature, &humidity, true) == 0) { Serial.print("T: "); Serial.print(temperature); Serial.print(" H: "); Serial.println(humidity); } Zip file included, source code lives at https://github.com/MORA99/Stokerbot/tree/master/Libraries/dht Note: This lib requires working micros, delayMicroseconds and pulseIn functions, if you are using it on CC3200 you may need to patch your Energia installation. dht.zip
  3. MORA99

    CC3200 bootloader

    In order for this board to reach its full potential, it needs to be programmable in the field, very much preferably without a usb cable and a laptop at the location. From what I can gather the code for the chip is stored in the external SPI chip and when we flash new firmware, we are using the ftdi to send uart to the cc3200 which in turn writes the SPI. Is it possible to replace this bootloader with something that can load a new sketch/hex file over the network ? If not then the only remote programming possible would be a lesser language that is interpeted and any firmware upgrades would have to be done locally. I have a similar issue with the wired launchpad, it uses a seperate chip to do the programming, which does not have network access, but maybe one could store it somewhere and then reset the programming chip.
  4. Very nice, I noticed that I get quite a few errors on dht in my project, but I sleep the chip alot so didnt investigate it much. You can send the changes to me by mail if you like, and I will update the github/lib.
  5. Since this board has been out for longer than the cc3200, maybe there is better hope for a network bootloader ? I found a few discussions on it, but not much to go on, maybe the board is not popular enough, or the ones that figured out how to do it dont share I would like to make the board boot info a bootloader area, preferably a energia sketch, which checks if thers a new firmware available and if so flashes it to the main program area before jumping there. Preferably the boot area would be protected, but even if not theres still the rom bootloader that would allow to recover over usb as far as I understand. I am looking for a ethernet arm chip to replace my old 8bit network controller, but without network update its not of much use. Any help/hints/pointers very welcome.
  6. MORA99

    TM4C1294 Network bootloader

    Hmm, I didnt think of that, obviously there are more flash than theres ram, so how would I make sure a specific part of my code is loaded in RAM while updating the flash ?
  7. static int8_t readFloatData(unsigned char pin, float *temperature, float *humidity, boolean dht22); The true/false is to set if the sensor is a dht11 or dht22, so thats intended. The main difference is precision and the dht11 requires a bit more delay.
  8. MORA99

    CC3200 Wifi delay issue

    First day with Energia, loaded it onto my 3200 in minutes, so sofar its a lot more user friendly than the TI offer I have been trying out the webserver demo, and noticed that if I dont include a small delay in every println the connection gets dropped, I am guessing this is some buffer being filled faster than it can offload to the webclient. The interesting part of the code is below, in the dummy printouts, if I lower delay to 1 or just remove it, the connection is closed pretty early, 5 seems steady, and 2 was not enough, so somewhere in between. The CC3200 is connected to a local wifi, not sure which speed though. if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); delay(25); client.println("Content-Type: text/html"); delay(25); client.println("Connection: close"); // the connection will be closed after completion of the response delay(25); client.println("Refresh: 5"); // refresh the page automatically every 5 sec delay(25); client.println(); delay(25); client.println("<!DOCTYPE HTML>"); delay(25); client.println("<html>"); for (uint16_t i=0; i<2000; i++) { client.println("Dummy"); delay(5); } Any ideas ?
  9. Sorry for late reply, see this thread for changes needed with the current energia release and CC3200 : http://forum.43oh.com/topic/5902-measure-short-amounts-of-time-with-micros/ Problem is that micros (and therefore pulseIn) and delayMicroseconds does not work correctly due to how the tick counter is handled.
  10. MORA99

    CC3200 LaunchPad Pins Map

    The jumper is used in out of box example to force it to run access point mode. The pin is 3v3 compatible, but only if its used as a digital input, if you change to adc mode with the jumper installed it may damage the chip, a bit dangerous.
  11. MORA99

    CC3200 : Control pins without digitalWrite

    Yea maybe, I will come back to it later, coming from Avr 8bit its a bit of a transistion working with 32bit magically wifi box
  12. I am trying to do some fast bit bang in C to see what is possible without going to asm. But I havent had much luck in doing a simple on/off or toggle using bit manipulation instead of calling digitalWrite. My noble attempt didnt really do much. uint16_t pin; uint8_t port; uint8_t mask; void setup() { pinMode(4, OUTPUT); pin = digital_pin_to_pin_num[4]; //PIN_03 GPIO_12 port = digital_pin_to_port[4]; //S1 mask = digital_pin_to_bit_mask[4]; //BV(4), /* 4 - GPIO_12 */ } void loop() { port ^= mask; delay(500); } I found digitalWrite in the sourcecode, and it calls MAP_GPIOPinWrite When then calls GPIOPinWrite or ROM_GPIOPinWrite Which then calls ASSERT and HWREG. So maybe I need to call HWREG to get as close to bit bang as possible ? By the way, I tested the digitalWrite function just to have a baseline, in a while(1) loop turning on and off the same pin, it gets 400ns pulses at 80MHz, so 32cycles if I did the math correctly.
  13. MORA99

    CC3200 : Control pins without digitalWrite

    In the final code I will know what state it needs to be, for now its just testing to see what is possible. To run WS2811 code from c I need toggles around 30-70 cycles and some time left to pull the bytes from a array.
  14. MORA99

    CC3200 : Control pins without digitalWrite

    Thanks, eventually I will have tight loops ... then we see if its enough
  15. MORA99

    CC3200 Wifi delay issue

    Very nice, now if only we could get smartConfig and networkBootloader
  16. MORA99

    CC3200 Wifi delay issue

    Wonderful the new files works, so it would be better to make a buffer locally before transmitting it to the CC3200 ? I guess most small packages is due to not being able to just string the output together on the fly, like "str"+val, but sprintf can do that. Also tested ssl connect against a rapidssl cert, it connects and sends/recieves data and it fails if I try to ssl connect to a non ssl server, so I think its encrypted, hard to prove though
  17. Sorry for derailing this, I am not that familiar with TI to realise which family cc3200 belongs to. It is probaly possible with SPI, a lesser wifi enabled device uses that to control ws2811, but you would be taking up a hardware SPI port, which is a pretty limited resource, maybe an analog switch could multiplex it. One could use a secondary 8bit mcu to offload the timing as long as fast updates are not needed. I see the adafruit avr code is assembler too, ofcause being ~16mhz theres fewer cycles to waste than at 80-120mhz, but 80mhz is still nowhere near enough to do it in c, I tried 2 inline asm sleeps with digitalWrite and its way off, maybe a direct bit manipulation could work, acording to the datasheet the leds dont really require perfect timing, theres +/-150ns on both high and low pulse, so +/-12cycles at 80mhz.
  18. MORA99

    Sha1 on the CC3200

    Thanks, I got it to compile with some small changes, and the test suite says all good
  19. MORA99

    Sha1 on the CC3200

    I am writing a websocket client on my CC3200, its working as it is, but its not verifying the sec key the server sends back, so thats next. But to do that I need to hash a value with sha1, and sofar I havent found any libs that compiles (or nearly compiles) on energia. Does anyone have a link to a library that works ?
  20. Works fine on my windows installation too, before I was not able to use printf because it overflowed (.heap can not fit in SRAM), with the new pde.jar "Binary sketch size: 60.152 bytes (of a 262.144 byte maximum)"
  21. Yea I looked at it, hoped it would be compatible Even at 80MHz the timing is pretty tight, 72 cycles for the long delay if I remember correctly.
  22. Any chance of getting this working on cc3200 ? I tried replacing the msp includes to energia.h, and made an attempt at the pin declarations, the compiler isnt impressed though #define WS2811_BITMASK digitalPinToBitMask(3) #define WS2811_PORTDIR portDIRRegister(digitalPinToPort(3)) #define WS2811_PORTOUT digitalPinToPort(3)
  23. MORA99

    Measure short amounts of time with micros()

    Jep, using something along the lines of that bugreport removes the wildly off readings. unsigned long k = 0; void setup() { pinMode(3,INPUT); Serial.begin(115200); // initialize serial communication } void loop() { unsigned long c; unsigned long x = 0; for (uint16_t i=1; i!=0; i++) { c = pulseIn(3, HIGH, 1000); if (c<16||c>24) x++; if (c<10||c>30) Serial.println(c); } Serial.print("Loop ");Serial.print(k++);Serial.print(" => ");Serial.println(x); } Output,each of those loops are about 65500 tests, so <10 errors is not bad, and none of them were outside +/-10us of the signal being read Loop 0 => 9 Loop 1 => 7 Loop 2 => 8 Loop 3 => 1 Loop 4 => 8 Loop 5 => 8 Loop 6 => 9 Loop 7 => 1 Loop 8 => 9 Loop 9 => 7 Loop 10 => 9 Loop 11 => 1 Loop 12 => 9 Loop 13 => 8 Loop 14 => 9 Loop 15 => 7 Loop 16 => 2 Loop 17 => 9 Loop 18 => 8 Loop 19 => 9 Loop 20 => 1 Loop 21 => 9 Loop 22 => 8 Loop 23 => 9 Loop 24 => 1 Loop 25 => 9 Loop 26 => 7 Loop 27 => 9 Loop 28 => 1 Loop 29 => 9 Loop 30 => 8 Loop 31 => 9 Loop 32 => 1 Loop 33 => 8 Loop 34 => 7 Loop 35 => 9 Loop 36 => 1 Loop 37 => 9 Loop 38 => 8 Loop 39 => 8 Loop 40 => 1 Loop 41 => 9 Loop 42 => 8 Loop 43 => 9 Loop 44 => 9 Loop 45 => 1 Loop 46 => 9 Loop 47 => 7 Loop 48 => 8 Loop 49 => 1 Loop 50 => 9 +/-4us is a bit much, but I cant say how precise my 20$ logic tool is either Whats odd is theres a pattern to the number of off readings, first 3 loops with 7-9errors, then 1 with 1error, and repeat, but without better equipment I cant say if that error is on the cc3200 end or my tool end. Now we just energia to implement a fix in an official release. This is what I am using atm. unsigned long micros(void) { unsigned long ms, cycles; do { ms = milliseconds; cycles = SysTickValueGet(); } while(ms != milliseconds); //If miliseconds changes while we read, we retry return (ms * 1000) + (((F_CPU/1000)-cycles) / (F_CPU/1000000)); } And for delayMicroseconds I use this (have not tested the ~70min rollover yet) void delayMicroseconds(unsigned int us) { unsigned long now = micros(); unsigned long endTime = now + us; if (endTime < now) //overflow { while (micros() > endTime); //Wait for micros to overflow before normal condition below } while (micros() <= endTime); }
  24. Tested on CC3200. I am trying to see how long a pin is held in one state, the time will be pretty short at most 100us. So I tried with micros() before and after, but didnt get good results, then I tried timing a simple pinmode and digitalwrite, that gave a negative or very large value... So I boiled it down to this example while(1) { unsigned long i = micros(); delayMicroseconds(100); unsigned long p = micros(); unsigned long o = p-i; Serial.print("Tooki : "); Serial.println(i); Serial.print("Tookp : "); Serial.println(p); Serial.print("Tooko : "); Serial.println(o); i = micros(); delayMicroseconds(1000); p = micros(); o = p-i; Serial.print("Tooki : "); Serial.println(i); Serial.print("Tookp : "); Serial.println(p); Serial.print("Tooko : "); Serial.println(o); Serial.println();Serial.println();Serial.println(); delay(1000); } I have made a time machine Tooki : 112690699 Tookp : 112690597 Tooko : 4294967194 Tooki : 112693032 Tookp : 112694699 Tooko : 1667 The numbers are stable, the funny part is that i-p is about 100, but p is set to micros() after the sleep of 100micro seconds so it should be lower than i. If I increase the sleep to 1000(1 mili second if I am not mistaken), then it works correctly Tooki : 4064995 Tookp : 4065995 Tooko : 1000 Tooki : 4067298 Tookp : 4068995 Tooko : 1697 This is tested in a while loop at the end of the setup function. I have searched for similar issues but they seemed to relate to using the function in interrupts, if thers another thread on the subject already, please send me in the right direction.
  25. MORA99

    Measure short amounts of time with micros()

    Okay, seems reasonable, so its to make sure both ms and sysTick was read in the same ms section, if ms overflows just as we read those two values, we retry.
×