Controller and software (alpha)

@zjwhitehead, speaking of codenames, maybe Icarus

@gla.torg You’ve done amazing job on this one. Sounds are ok.
I’ve seen the work on a test stand - it operates fine.
What is Beginner - Intermediate - Advanced?
What are these modes meant for?

Thank you! Beginner, Intermediate and Advanced for now acts only on the smoothness of the throttle response, from 0 to 500ms of “delay”. It act on the number of analog readings before send it to the ESCS.
This is the part of the code:

// -------------READINGS THUMB--------------
 ThumbRaw = analogRead(A0);            // read from the sensor
switch (UserMode) {
case 1:// Beginner
      ThumbTotalBeginner = ThumbTotalBeginner - readingsBeginner[readIndex];
      readingsBeginner[readIndex] = ThumbRaw;
      ThumbTotalBeginner = ThumbTotalBeginner + readingsBeginner[readIndex];
      readIndex = readIndex + 1;
      if (readIndex >= numReadingsBeginner)
        readIndex = 0;
      Thumb = ThumbTotalBeginner / numReadingsBeginner;    
      break;

case 2:// Normal
      ThumbTotalNormal = ThumbTotalNormal - readingsNormal[readIndex];
      readingsNormal[readIndex] = ThumbRaw;
      ThumbTotalNormal = ThumbTotalNormal + readingsNormal[readIndex];
      readIndex = readIndex + 1;
      if (readIndex >= numReadingsNormal)
        readIndex = 0;
      Thumb = ThumbTotalNormal / numReadingsNormal;  
      break;
      
 case 3:// Advanced
      ThumbTotalAdvanced = ThumbTotalAdvanced - readingsAdvanced[readIndex];
      readingsAdvanced[readIndex] = ThumbRaw;
      ThumbTotalAdvanced = ThumbTotalAdvanced + readingsAdvanced[readIndex];
      readIndex = readIndex + 1;
      if (readIndex >= numReadingsAdvanced)
        readIndex = 0;
      Thumb = ThumbTotalAdvanced / numReadingsAdvanced;   
      break;
  default: 
      UserMode = 1;
  break;
}

Depending on the power output in the future shoould set also the maximum power.
What do you think?

@gla.torg
I’ve heard about Arduino but never tried it out myself. Which language do they use? It resembles C++. I’m familiar with C#.
Are these double or integer values in your code?
E.g., numReadingsNormal, numReadingsAdvanced, numReadingsBeginner.
Is there a way you check that these variables are not zero to avoid a zero divide exception?

UPD: Oh yes, I see these are const integer values…

General questions for understanding:
Q1: I’m not familiar with actual real-world robotic software applications. Why do you have to read the throttle more than once? Does it mean that software will ignore throttle position fluctuations?
Does feature depend on time/duration of the throttle position?
How does analog reading work in general? (If you have time).
Q2: What does PWM stand for?
Q3: Why do you measure power in microseconds?

Yes, something from C language, I don’t know more :sweat_smile:
The analog reading is reading the difference from Voltage reference and Voltage from the potentiometer (variable resistor)
You don’t have to read analog more than once but it helps to keep the value stable (a sort of average)
Keep in mind that the readings in Advanced are 2 only (just to keep the software works in the same way for each UserMode)
PWM is for Pulse Width Modulation that is the standard to communicate with the 99% of the ESC from rc/hobby market, and the values are Microseconds
Sorry if I’m not so technical but I’m not an expert, I just google everything, search for examples and put together :sweat_smile:
pwm

1 Like

Hey guys, I was going to add to this thread but my reply ended up being pretty long haha. Check out my new post for info on some of code behind our early features.

2 Likes

What about ebike sine wave controller style. Like a Sabvoton.

Ebike controllers are especially designed for low RPM, high torque applications. We do just great with hobby ESC - because what were looking for is higher RPM control. And hobby ESCs are way cheaper and lighter!

2 Likes

I only have one suggestion. Instead on the long press maybe you can use 5fast clicks to activate. It is harder to arm it by accident.

1 Like

It is C++. Arduino is just a library.

gla.torg:

Thanks for the V1 schematic and preliminary code. I agree that Teensy controller/Teensyduino development environment is ideal for this project.

I wonder what was your intent with including VL53L0X? Perhaps an alternate throttle position decoder (optical vs potentiometer resistance measurements)? In which case, does VL53L0X has enough resolution for throttle position?

I haven’t experimented with time of flight sensors yet but it looks like a better one for our application would be the VL6180X. It is more geared towards shorter distances. 100mm is probably the max distance that it would have to measure.
Do any of you have experience with these types of sensors?

I don’t have experience with “time of flight” sensor but I am anxious to experiment with them. I have VL6180X on order. I am curious if the IR signal of these sensors and therefore the distance measurement would be negatively impacted by the confined space of a throttle body…

Even with this optical approach, I am leaning towards determining throttle position via reading a pair of ganged potentiometers. Some refer to this as “dual track”. Each of these pots would have positive but diverging slope response (position vs voltage output). This configuration increases confidence of the measurements but more importantly, it facilitates diagnosis of malfunctions… (detection of broken wires (open circuits), shorts to ground, shorts to power or even resistive “shorts”). Obviously, the flight control code would need to perform these diagnostics periodically and alert pilot accordingly.

Anyway, I’ll report back any findings on VL6180x…

Why aren’t you using an ESP32 or ESP8266? They’re arduino platform compatible, very cheap, have reliable WiFi, low power and can shield a memory slot. The 32 even has Bluetooth which could be used for anything.

Got a link to your favourite version for this type of use?

Really depends on what is necessary. You can choose anything from just the esp module to a dev board, just like arduino. ESP8266 is the lesser capable (like teensy) to the new ESP32 with high processing capabilities.

Wemos is a popular manufacturer, very cheap on AliExpress.

There’s even dev boards with LoRa(long range comm) and OLED screens for $13.
http://s.aliexpress.com/N3Yra2Uj #120 LoRa / LoRaWAN Range World Record Attempt. Will I succeed? - YouTube

We started off with the Arduino nano mostly because they are very popular and cheap. I found that for the handful of features in the first version it is plenty capable and reliable.

However I’ve recently started experimenting with some faster chips and the Teensy platform.
The code is pretty straightforward so I’m excited to see what features and improvements you guys come up with.

Bluetooth is especially interesting because it opens up the OpenPPG platform to the outside world, especially phone apps. We’re just getting started but its always good to be thinking about the future :slight_smile:

Well, you’re in luck because there’s support for ESP in the Arduino platform. Shouldn’t have to change your code.

Experiments are complete! VL6180X was connected to a Teensy 3.6 controller for test runs (could have connected to any micro with I2C communications).

Conclusions: VL6180X Time-of-Flight (TOF) is nice little sensor for proximity detection in an OPEN environment. TOF sensor not good for this application. Any surface close to the infrared emitter causes backscatter and the sensor readings become unreliable. So infrared beam is not as collimated as I was expecting (I know!.. too good to be true). I would not use this approach to determine throttle position!

I’ll stick to reading potentiometers…

1 Like

Thanks for the update! Glad we have a definitive answer on this.