-->
Page 1 of 1

Arduino & ESP8266 speed of processing

PostPosted: Sun Jul 17, 2016 8:52 am
by simon5030
Hello
First post so go easy on me!
My base level of programming is VB but am just getting to grips with the basics on Arduino.
I am trying to build an application using a Nano and ESP8266, the basics of the application is to monitor a machines status including cycle time and production count and then send that information via the ESP to a listener IP.
The Nano monitors a digital input (cycle count), this can vary from 2sec to 30sec, so if i try and send anything by WIFI (using AT commands) the delays needed for establishing a connection and sending data will cause the loop to miss a count. In VB i would have created multiple threads to make this work but that's not possible?
I have looked at an interrupt, I have already set one up to monitor the voltage line for power loss and write the counter values to EEPROM, this works great because it processes so fast. The bit i am unsure about is that if i use an interrupt for the machine cycle it will process up to every 2sec, this will not allow the sending of the data?
It may be possible to trim some time off the delays but it needs to work as a disconnection process as there will be up to 50 machines online, i only need to send machine data maybe every 5mins or so but each time it stops the monitoring of cycle count.
I didn't think it was worth posting the code so far because the current code does what it is supposed to, its more a process conundrum and methodology that i need some guidance with if anyone has any ideas?
Maybe run 2 Nano's and get one to send the data while the other carries on processing?



Thanks in advance
Simon

Re: Arduino & ESP8266 speed of processing

PostPosted: Thu Jul 21, 2016 9:41 am
by mrburnette
I'm just thinking out-loud, so do not take anything here as the absolute-truth:

On the ESP8266, the user-code for Arduino runs in a proto-thread'ish manner and the user code must return to the native RF section code no longer than every 50mS to refresh the radio and protocols. This is magically done in the void loop{} with every iteration ... but, the user code MUST return to the loop under 50mS. This can be done with delay(0) or yield(0) or any use of delay(n)... so, it is important that the programmer analyzes their code and profile the sections are routines.

You can increase the frequency from 80mHz to 160mHz if your power budget will permit.

You will need to logic-level interface between 3.3V and 5.0V

Use of ESP8266 interrupts should work correctly but (I have not looked) any ESP8266 interrupts utilized by the RF section will likely disable interrupts during that section of code/callback. So, there may be some jitter in your timing from other interrupts... not just an ESP8266/Arduino issue.

I do not see the need for "AT" commands... the above thinking is for Arduino programming of the ESP8266.

Ray

Re: Arduino & ESP8266 speed of processing

PostPosted: Tue Aug 02, 2016 3:04 pm
by simon5030
Ray

Thanks for the update, sorry its taken me so long to get back to it!
It makes a bit more sense with what you have said.

I have changed things a bit and now i am using 1 nano running a fast loop for processing and sending data to LCD via i2c, i have managed to incorporate an interrupt to detect power loss and save values to EPROM. This is where it got a bit sticky though, it seems as though at some point i have managed to pull enough current to burn out the AMS1117 voltage chip and that's rated at 1A!!! the bad bit was that it didn't fail safe and brought the voltage up to 12V on the Nano, yes they went pop!

Trying to find the cause and in my voltage detection i am running a diode to 2 470mF caps and i am wondering if when its been turned off then restated that the caps have to charge up and pull the excessive current? Tried to prove this with meter and recreating the situation but no luck??

More testing and i am sure i will get there, once the above has been solved i can move on!
I do have some strange anomalies that i cannot explain?
When i put any reference to the LCD outside the main loop it seems to ignore it, ie in a sub routine that is called from the interrupt (need to turn the LCD off to buy some time with the caps to write to EPROM)