OS DAVEGA essentials

This thread is to backup some important posts from the esk8.builders in case it ever gets shut down completely.

To be clear, there are two types of DAVEGA. The OS DAVEGA is the original one. Both software and hardware is open source and available on GitHub.

DAVEGA X is closed source and can be ordered from https://davega.eu/, though it’s rarely on stock (I’m working on improving that :smile:).

This thread relates to the OS DAVEGA.

Here’s how it all started.

Original esk8.builders post

It’s a gadget that you plug into a VESC based controller to display some of the most important data, such as battery status, speed and distance travelled. It not only displays the data, but it also stores them and thus it doubles as an odometer. The design is Arduino compatible and thus the firmware can be easily customized without any special equipment.

I know that there have been a number of similar projects, but I wanted a display with nice graphics (instead of text only) and I wanted it to be compact. BTW, the graphics is inspired by @Pimousse’s smart ring .

I thought that the gadget would be best demoed in a video. So here it is. Please bear with my presentation skills. :smile:

Some noteworthy features:

  • uses both battery voltage and coulomb counter for estimating current battery capacity
  • data retained after powering off and on again
    • updated in reasonable intervals so that the EEPROM doesn’t get destroyed (should last for 10,000 km)
  • automatic detection of battery fully charged => resets the coulomb counter
  • odometer can be initialized to a custom value
  • firmware customizable with Arduino IDE
  • low cost - less than $10 for the parts
21 Likes

OS DAVEGA with Arduino Nano:

7 Likes

Making a basic cable

Original esk8.builders post

Edit: After writing it all down and taking all the pictures I realized that the 4P connectors are different from the batch I ordered earlier. The guidelines below assume the 4P connector looks as follows

which is apparently not the case for some of the kits I distributed. So as a preparation step you will want to unpin the wires from the housing and plug them back so that it looks as on the picture above. Then on the pictures below, let’s pretend this has already been done. :sweat_smile:

At the end of the day, the Dave has to be connected to the VESC as follows (5V-5V, GND-GND, RX-RX, TX-TX):

Sorry for the confusion! I will update the guidelines later.

I realized that maybe it’s not completely obvious how to get from here:

to here:

so here’s how to make the DAVEga-VESC cable. If you have crimping pliers and JST-PH crimps, that’s ideal. I guess that most people don’t though. No worries. You can do it just with a soldering iron as well.

First, you will want to unpin the wires from one of the 4P housings. I do it with a very small screwdriver. A needle should also work. You will want to lift the piece of the plastic that holds the crimp. Then you can unplug the wire.

You can be rough with the housing since you won’t need it. Be careful not to damage the crimps though.

You will get four crimped wires.

Now, depending on your VESC type, you will want to take either the 7 pin or the 8 pin JST-PH housing (both come with the kit) and plug in the wires correctly. Check your VESC UART connector. The color mapping is as follows:

  • red - 5V
  • black - GND
  • white - TX
  • yellow - RX

Here’s what it looks like for FOCBOX (and Unity). I believe this is the most common pinout.

If you happen to have @stewii’s ESCapes, you will want to have the wires plugged into the housing as follows (completely different from FOCBOX):

Then you simply solder the 4P and 7P (or 8P) parts together (I didn’t have white heatshrink :slightly_smiling_face: ):

Depending on where you want to install your Dave, this will likely be too short, so you will want to use an extension.

You can either use a 4 conductor cable:

or 4 individual wires. 26 AWG is ideal but anything in the 20-28 AWG range is usable. Here’s what the end result should look like.

Also, you don’t have to use the 4P connector but instead solder to the Dave PCB directly.

It doesn’t matter whether you solder on the VESC port or on the USB-UART port. These are the same rails. You can actually easily see on the PCB how the pins are connected (RX=RXD, TX=TXD, etc).

So feel free to solder on the USB-UART if that’s easier for you. It all comes down to what kind of enclosure you use and how you route your wires.

See also here for how to make a more advanced harness that can also be used for updating the FW.

2 Likes

Making an advanced cable

Original esk8.builders post

Here’s my take on the harness. I used a 5 conductor cable and put a JST-XH connector so that I can connect the USB adapter. Then I made an adapter from 5 pin JST-XH to 8 pin JST-PH to use for connecting to VESC. Works like a charm.

3 Likes

Misc cable ideas

Original esk8.builders post

TODO: copy pics

Some thoughts about wiring things up. Ideally, we would have a single cable going out of DaVeGa that we can connect either to VESC or to the USB-UART adapter for programming.

There are 5 pins on VeGa:

  • 5V
  • GND
  • TX
  • RX
  • DRT

The VESC connects to the first 4. The USB connects to all.

Here’s the pinout of the devices to be wired up (for the VESC, this is how my ESCapes look like; I think that other VESC derivatives have a different pin order, but that doesn’t really matter):

0b8e3a509c0d4e4ea5370677a9b38c8a38f6d388

Now, one option is to simply split 4 wires and add two connectors. That’s what I have done here. But, it’s pretty annoying having to split 4 wires and you end up with the dupont connector dangling around all the time when it’s only used rarely.

An alternative would be to make an adapter. It’s natural to go from more wires to fewer wires, i.e. from USB to VESC. But, that wouldn’t be very reliable since the dupont connectors tend to slide off. Plus, the device that’s plugged-in most of the time (the VESC) would go in via an adapter. Not ideal.

We can go the other way around, but that means the DTR wire would need to be separate. It’s not a problem to connect the 6 pin USB-UART to two (1+5 pin) dupont connectors. This would work just fine. We would end up with only a 1 pin dangling connector. No Y-splits needed.

An even better option would be to connect all 5 VeGa pins to the VESC and then make a simple adapter to the 6 pin dupont without the stand-alone wire for DTR. I think that it should be OK to connect the DTR to one of the VESC’s ADC pins. DTR is high (5V) in a normal state, but I believe the ADC pins are not used for anything by default. The only problem would be if the ADC is pulled low since that would reset the VeGa, but that shouldn’t happen. Could someone with a better knowledge of the VESC HW please confirm this? @Kug3lis maybe? Thanks! I know this is a hackish solution, but it seems the simplest and most elegant.

Last but not least, it’s not necessary to connect the DTR at all. Then we would need an extra button for resetting VeGa manually. It’s not hard to reset manually at the right moment when updating the FW. Still, it’s an extra button.

After more thinking, we could just do this:

… but use JST XH instead of the dupont. The JST won’t slide off and 2.54mm spaced pins of the USB-UART can be plugged into a female JST XH directly. It would still mean the VESC goes in via an adapter, but I guess that’s fine.

1 Like

Coding crash course

Original esk8.builders post

Alright, guys. It’s time to teach you some fishing since I don’t have enough fish for everyone.

Currently, there are 4 DAVEga screen layouts:

  • default

  • simple vertical

  • simple horizontal

  • text

The layouts to be used can be configured here and then you can toggle between them with button 3. Normally you’ll want to enable 2 layouts: the text and one of the graphical ones. It doesn’t really make sense to enable more than 2 though you could.

The code is modular and each screen layout is one class:

You can customize existing layout by editing its class. (You can even add your own new layout. Just use any of the existing layouts as a template. This is not completely straightforward so I only recommend it to people with some coding experience.)

Now, let’s have a look how to get basic things done. To display a value, you’ll want to do two things:

  1. create a label for it
  2. display the actual value

Say that we want to modify the simple vertical screen such that it shows BATTERY AMPS instead of TRIP KM.

First, we’ll go to the reset() method where the labels are drawn. We’ll want to change the following line:

_tft->drawText(0, 130, _config->imperial_units ? "TRIP MI" : "TRIP KM", COLOR_WHITE);

to the following:

_tft->drawText(0, 130, "BATTERY AMPS", COLOR_WHITE);

By that we’re simply saying to write the text BATTERY AMPS in white color at coordinates [0, 130]. In the original, the ternary expression may look scary:

_config->imperial_units ? "TRIP MI" : "TRIP KM"

This simply says: write TRIP MI if the _config->imperial_units flag is true; write TRIP KM otherwise.

Second, we’ll go to the update() method where the values are displayed. The reset() is only called at the screen layout initialization whereas the update() is called periodically several times a second.

There we’ll want to locate the following code, which displays the trip distance:

    // trip distance
    dtostrf(convert_distance(data->trip_km, _config->imperial_units), 5, 2, fmt);
    tft_util_draw_number(_tft, fmt, 0, 140, progress_to_color(data->session_reset_progress, _tft), COLOR_BLACK, 2, 6);

and change it to something like this:

    // battery amps
    dtostrf(data->battery_amps, 5, 1, fmt);
    tft_util_draw_number(_tft, fmt, 0, 140, COLOR_WHITE, COLOR_BLACK, 2, 6);

Now, let me explain what all of that means. The first line is just a comment. On the second line, we convert the float value data->battery_amps to a string value in fmt

    dtostrf(data->battery_amps, 5, 1, fmt);

The 5 is the total number of characters including the decimal point; the 1 is the number of decimal places. For example, the value of

123.4466666666

would be formatted as

123.4

That’s 5 characters and 1 decimal point precision. If the value is less than 100, there will be leading spaces. For example:

5.339999999999

would be formatted as

__5.3

(two leading spaces). This ensures the value is right-aligned.

On the third line, we display the value stored in the fmt variable.

tft_util_draw_number(_tft, fmt, 0, 140, COLOR_WHITE, COLOR_BLACK, 2, 6);

The parameters are as follows:

  • _tft - reference to the display instance (don’t worry about it)
  • fmt - the string to display
  • 0 - x coordinate
  • 140 - y coordinate
  • COLOR_WHITE - text color
  • COLOR_BLACK - background color
  • 2 - number of pixels between characters
  • 6 - font size

In the original code, instead of COLOR_WHITE for text color, there’s the following expression:

progress_to_color(data->session_reset_progress, _tft)

This is to dim the text when the session data is about to be reset. As you press and hold the button 1, the data->session_reset_progress value will gradually increase from 0.0 to 1.0 and the progress_to_color() function translates the value into appropriate color (higher = darker). Once the data->session_reset_progress reaches the value of 1.0, the session data is reset and the value becomes completely black. You don’t need to worry about this. It’s just to explain what’s going on.

The last thing you need to know is what values are available in the data . You’ll find the list here . For example:

data->speed_kph

will give you the current speed in km/h. Session data can be accessed using double dereference. For example, this is how to get the max speed in km/h:

data->session->max_speed_kph

The list of values available in the session is here .

I hope this is helpful and I’m looking forward to seeing many customized screen layouts. :slight_smile:

9 Likes

Thank you @janpom!

Do you plan on further developing the OS version?
Maybe transfer some updates from the X?

1 Like

No immediate plans. Updates from the X are not easy to transfer since it’s a completely different platform and a different programming language. The X firmware is written in micropython.

I’m thinking of making a few more OS DAVEGA DIY kits though if there’s interest. I kinda miss those. :slight_smile: It’s also a shame that the nice 3D printable enclosures that @LR-designs, @mmaner, and Jonathan designed are not more widely used since the Flipsky version of the OS DAVEGA is too big to fit in those.

3 Likes

I am game.

How much would those cost approx?

2 Likes

Maybe $20-$25 with a nice cable.

3 Likes

I’ll take 3 sets.
(I’d appreciate if it came with a 3D printed case)

1 Like

I would be game too

2 Likes

Man, I said I’m THINKING about making more kits and you’re already placing orders. :smile:

Would a DIY kit be OK? Here’s the assembly video: https://youtu.be/QPjD0Zebh9U

I don’t have a 3D printer so unfortunately can’t help with the housing.

5 Likes

Yeah, totally, I want this to be DIY!
I am just too ignorant andor lazy to source the correct parts in the correct quantity (buying one connector often costs more than buying ten).

3 Likes

@PrivacyDoctor, if you need housings printed, I can do them for you. Maybe cheaper to just do it locally but thought I’d offer

2 Likes

I have access to printers, I just haven’t done it before. But it will be a good way to get myself started. :slight_smile:

Thank you for the offer @annihil8ted

1 Like

On a side note

Does anyone have clear instructions how to add ‘Watts’ function and maybe even get ‘WH/Km’ and ‘Kilometers left’ options?

I know one user on the esk8 builders forum managed to get the Watts showing up + implemented some more ‘data values’ on the screen, I would be interested in doing the same but he didnt leave much information on how to do so.

(Example)

Just recently connected DaveGa (1st gen) and quite happy with the result but some more data options would be nice.

Info is here:


"


"
It is just a bit hard to make out which step is which as I believe there is some commentary from @janpom himself.

Ok, by posting this I got to understand I need to switch Items to something I want to see, though I guess I will need a good hour or two to really figure this out

1 Like

I am having some trouble getting numbers to show up.

I have the FSESC set to PPM and UART, the baudrate set correctly and the arduino nano all wired correctly. I am getting power and ground off of the FSESC UART port, but no data on the screen. I have even tried another esc and nothing still.

Settings sound correct. My bet would be there’s a problem in wiring. Swapped RX/TX maybe?

1 Like

Yeah I did that. I am going to make a wire harness with soldered connections rather than breadboard wires plugged into the back end of a UART harness shortly to skip over the sketchy bit.

The switching of TX and RX and the switching of ESC’s makes me to think that it’s just simply not getting 1 of the signals, or both.

Thanks for the input! Time to get back in the garage!