Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Ash
@ashthespy
The more I look at it my code - the more I see how I just got lucky.
Chris Dalby
@moose4621
@devyte serialize?
Develo
@devyte
if you're sure that your values will always fit in a uint16_t, then your original approach is not too bad. You probably want something like this:
void sendSettings() {
  uint16_t data[] = {setpointVariable, targetGroundSpeed};
  webSocket.broadcastBIN((uint8_t *)(&data[0]), sizeof(data));
}
Ash
@ashthespy
As makuna pointed out - this needs to be deserialized big endian though for the esp8266
Chris Dalby
@moose4621
@devyte That's great. I know my int will never exceed 300 but I need to understand this anyway.
Ash
@ashthespy
@moose4621 why aren't you using floats?
Develo
@devyte
I was just about to say that the above works only for the endienness of the ESP
Ash
@ashthespy
@devyte is there a more agnostic approach to serialisaion/deserialsation for embedded stuff?
agnostic to datatypes that is
Chris Dalby
@moose4621
@ashthespy I got scared of using floats for calculations after I tried to to some PID stuff and was getting weird returns. Posted my problem to arduino forum and was jumped on for doing float calcs.
Ash
@ashthespy
I mean, is one supposed to sprinkle >> and << each time?
Develo
@devyte
none of these uC have hw floats. All floats are software, which means that float-based calculation is rather expensive. That said, the AVR is pretty weak compared to the ESP, which is most likely why you got jumped. Doing floats on the ESP is still expensive computationally, and there is a lot of code that is linked in for the float stuff, but it shouldn't have trouble calculating a simple PID
Chris Dalby
@moose4621
@ashthespy Quote from wiki"Floating point numbers are not exact, and may yield strange results when compared. For example 6.0 / 3.0 may not equal 2.0. You should instead check that the absolute value of the difference between the numbers is less than some small number."
@ashthespy So I just avoid floats untill human interface time.
Develo
@devyte
btw, are you doing a manual PID calc, a time-difference PID, or a Z PID? a manual PID, which is the most common, is also usually the most expensive, and it usually has control instabilities because the calcs don't take into account the time discretization
Chris Dalby
@moose4621
@devyte That project is long gone. Now using a stepper motor instead.
Ash
@ashthespy
@moose4621 there is always some numeric precision that you have to account for. -- There is no one golden rule - so you need to evaluate case by case if the penalty for floating point arithmetic is going to slow you down
Chris Dalby
@moose4621
@devyte @ashthespy As much as I really want to stay here and pick your collective brains, I am late for work. But thank you to you both. I appreciate it.
Develo
@devyte
oh ok :) just wondering. It's been a long time since I've had my hands in automatic control, I kinda miss it. I wrote a doc about PID controller theory some time ago for openservo.
about work, that reminds me that I'm done with it, and I gotta head home :p later all!
Ash
@ashthespy
it's bedtime for me -- cya!
den har
@denman0000_gitlab
Hi all ... seems I missed the party :-( lol
den har
@denman0000_gitlab
@devyte Too little time indeed .. our days of information overload .. it's no wonder TCIP/IP only surfaced when it did hey ... whoever time limits the well kept global secret perhaps have made wise decisions it seems
Develo
@devyte
I'm still around
den har
@denman0000_gitlab
@devyte coolio
@devyte ..perhaps you could help with a few simple questions that are driving me loco
@devyte they aren't code but are design related
den har
@denman0000_gitlab
@devyte hehe or not :-)
Develo
@devyte
aight, as long as I'm around, shoot
Chris Dalby
@moose4621
@denman0000_gitlab You there mate?
Chris Dalby
@moose4621
@devyte Thanks for your help earlier today. I tried your first suggestion for the payload array casting and it works great. I was hoping you could tell me why console is now reporting to be 3 or 4 arrays being sent over websockets.
ArrayBuffer(4) {} [[Int8Array]] : Int8Array(4) [42, 0, 53, 0] [[Int16Array]] : Int16Array(2) [42, 53] [[Int32Array]] : Int32Array [3473450] [[Uint8Array]] : Uint8Array(4) [42, 0, 53, 0] byteLength : (...)
@devyte or is it the same array being read 4 different ways?
den har
@denman0000_gitlab
@moose4621 hello how are you ?
@moose4621 @devyte @ashthespy Hello there
Hello all actually :-)
anyone around ?
Chris Dalby
@moose4621
@denman0000_gitlab Howdy.
den har
@denman0000_gitlab
@moose4621 Howdy howdy ...How are you ? :-)
Chris Dalby
@moose4621
@denman0000_gitlab Great, and you?
den har
@denman0000_gitlab
@moose4621 glad you're well and I'm great too :-)
@moose4621 I think I found part of what I was looking for .. Its a very basic example but shows how to get the variables across
Chris Dalby
@moose4621
@denman0000_gitlab Awesome. That's got to make you feel better.
den har
@denman0000_gitlab
@moose4621 only things is it seems to print the output on the console a number of times .. can't seem to see why
@moose4621 ...LOL one would think , sadly the closer I seem to think I am the further away I seem to feel ..if that makes sense
@moose4621 I was thinking about all last night and looking at the original arduino code I have .. and hopefully have now broken down the steps,
Chris Dalby
@moose4621
@denman0000_gitlab Hmm, nothing jumps out at me yet.
den har
@denman0000_gitlab
@moose4621 ... The order is as follows :
1.read a file from spiffs to populate a table on Webpage as well as an array on the C++/arduino side.
  1. If a row is added grab the data from input fields and update the table .
  2. get that row info into variables and populate array
    (at same time write the array field to a file on spiffs) .
@moose4621 sorry steps are 1,2,3 lol something weird in formatting here
@moose4621 currently that code returns multiple entries in the serial console when you click save only once :-( see here :
Hours: 12
Minutes: 01
Seconds: 27
This is server arg: 12
Hours: 12
Minutes: 01
Seconds: 27
This is server arg: 12
Hours: 12
Minutes: 01
Seconds: 27
This is server arg: 12
Hours: 12
Minutes: 01
Seconds: 27