Bringing TBI and Multi Port Fuel Injection to a New Level.     EFI Conversions and Tuning! Seattle to Portland! E-mail Tuning Consultant!
Results 1 to 9 of 9

Thread: segment gauge

  1. #1
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402

    segment gauge

    i have a custom bike with no room for the stock gauges anymore.

    i tried to do the trailtech thing that a lot of stripped down motorcycles use, but the reed sensor magnet junk and the small hard-to-read lcd with a poor backlight were just no good

    i reset my goals to 'visible without staring at it' and 'small' and 'uses stock speed sensor'

    so i've set out on a mission to turn these two things into my new instrument cluster:





    they were really cheap, and the display and board together are about 1.25x2".. all the lcd units i saw had fairly low visibility.

    it's turning out to be easier than i thought to get all this working on the bench

    the display connects to the arduino over SPI, so only need 4 wires to the dash (power, ground, and two for comms), then i'll hide the arduno near the airbox somewhere. i haven't actually powered up the display but i've heard they're bright as fuck (dimmable on command of course)

    i've managed to get the stock speed sensor working reliably with the analog input on the arduino (luckily it was already 0-5v). used a voltage switching point, only counting the rising edge. it runs up its counter for a fixed length of time, calculates for hz and starts over. it will have two accumulators for trip and odo too.

    i figured out pulses per wheel rotation by marking my tire and spinning it a few times while spitting out total pulses on the arduino's serial port

    most of the other sensors (oil, FI error, fuel reserve, etc) when run to the stock gauge pull to ground when in a bad state, so it looks like can use the arduino's internal pull-up and plug 'em right into the digital inputs. one exception is the signal indicators, but i think i'll throw a small relay and a few diodes in there so it'll just ground a pin when they're flashing too.

    my idea for the display logic itself (since there's a bunch of input data but only 4 digits to roll with) is to automatically cycle between all available data, which when normally riding and everything else is normal, is just the speedo.

    for example if oil pressure goes low while in motion, it'll flash 0IL, speed, 0IL, speed. if stopped, and the speedo was zilch, it would just display 0IL.

    it has those decimal point dots, i might use that as neutral light? signal indicator? (might be too small, we'll see)

    still haven't figured out a housing for the display yet, how/where to mount it, or how to protect or power the arduino itself which definitely needs to be weatherproof, but it's almost a gauge.

    anyone else made anything like this or see any disasters approaching?

  2. #2
    Electronic Ignition!
    Join Date
    Nov 2014
    Age
    33
    Posts
    16
    Sounds promising. Having cheap microcontrollers available for general purpose use has made so many things possible. I plan turning one into a trip computer for the roof console in my truck and controlling it through the steering wheel controls.
    Something you may consider is using a higher character count display like a 2x20, they are extremely cheap and well supported as well. You could have multiple stats on screen at the same time or use a large font and display only one. It would be less limiting.
    1995 K1500, Cadillac 500 TBI with 4L80E swap. In progress.

  3. #3
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402
    Something you may consider is using a higher character count display like a 2x20, they are extremely cheap and well supported as well.
    i looked at those but im thinking the segment display will be much more readable in peripheral vision, not just char size but also having pure contrast. (a bit more important for a bike than a car for sure) it'll also force me to keep things really simple and non-distracting

  4. #4
    Fuel Injected!
    Join Date
    Sep 2016
    Location
    Fort Collins, Colorado
    Age
    58
    Posts
    40
    I think this is fantastic! My only advice would be to use the Arduino Nano instead of the UNO. The NANO will still have more pins and function than you need and will probably fit behind the display. You can pick up the NANO's pretty cheap too. I buy from both SparkFun and Adafruit when I'm after genuine Arduino. Ebay clones from china when the money is tighter...

    unonano.jpg

  5. #5
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402
    you're right, i could have used that, but no real need for a smaller one. next project i'll consider it, i didn't realize the nano still had so many useful pins

    i would not go behind the display regardless in this situation, mostly for purpose of wiring clutter

    on a bike your wires mostly hang out. power/ground/speed/neutral/oil/fi/signal/temperature/etc including any transistors/diodes/relays involved is a large harness bundle.

    if i hide the uno in the frame and just run external wire for the display, i could even use an old usb cord for the harness, since it only needs 4 tiny wires

  6. #6
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402
    one odd thing i didnt' expect... last time i 'scoped a bike speedo, it was 3 pulses per output shaft revolution, which in my head i was thinking was a pretty low polling rate required.

    this one is apparently 27. no idea why they'd make it so high resolution, after the sprockets, it gives me 83 pulses per wheel revolution.

    since my tire is about 1 meter in circumfrence, and my top speed is 290kph = approx 80 meters per second (not that i'd ever go that fast....), that means at top speed i'd be in for about 6600hz of maximum sample rate.

    arduino docs say:

    It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
    i have to ensure my code polls it quickly enough to not miss a bunch of clock cycles at higher speeds... things like EEPROM WRITE clock in at 3ms each, so i'm going to ensure the odo/trip values don't get stored unless at low speed.

    i tried my best to make it work on a digital pin, but the hall effect sensor signal is too unreliable, and the ECM runs in parallel and supplies its own pull up and 5v (actually more like 4.5v) reference which doesn't quite match the arduino... with the analog input i pretty much have an oscilloscope at my disposal, i just have to translate the analog state to binary with a large switching threshold to reject any noise near the switch point.

    Code:
    // the speed sensor's voltage switching threshold, 0=0v 1023=5v
    #define SPEED_SWITCH_HIGH 700
    #define SPEED_SWITCH_LOW 300
    Code:
    int speed_input_state() {
      static int previous_state = LOW;
      int v_in = analogRead(PIN_SPEED);
      if(previous_state == LOW && v_in > SPEED_SWITCH_HIGH) { // switched to HIGH state
        previous_state = HIGH;
        return HIGH;
      }
      if(previous_state == HIGH && v_in < SPEED_SWITCH_LOW) { // switched to LOW state
        previous_state = LOW;
        return LOW;
      }
      // state unchanged
      return previous_state;
    }
    then the accumulator only counts rising edge:

    Code:
    void process_speedometer() {
      static int speed_state_last = LOW;
      int speed_state_current = speed_input_state();
      if(speed_state_last == LOW && speed_state_current == HIGH) { // rising clock edge
        speed_switch_count++;
    ...
    since this code relies on detection of the falling edge even though it's not detected, it might start acting up at high speed. might need to think of a better way.

  7. #7
    Fuel Injected!
    Join Date
    Sep 2016
    Location
    Fort Collins, Colorado
    Age
    58
    Posts
    40
    Would it by any chance help to condition the input from the speed sensor with a dedicated IC, and then use a faster digital pin on the arduino instead of the analog pin for counting pulses?

    http://www.ti.com/lit/ds/symlink/lm1815.pdf

    https://www.ebay.com/itm/1-PCS-LM181...from=R40&rt=nc

  8. #8
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402
    really i think it was just sampling with arbitrary intervals that was the problem. i just changed my strategy so speed sensor polling happens in a tight loop for >50ms. there's a lot of dead air while displaying stuff.

    the only reason i wanted to catch every sample rather than overall frequency was a total pulse accumulator so i'd have a perfect odometer, but i'd gladly sacrifice that so i don't loose speedometer precision at high speed.

    i'll just calculate a rough average meters per second for an interval and feed the odo/trip accumulator with that, should be accurate enough.

  9. #9
    Fuel Injected! steveo's Avatar
    Join Date
    Aug 2013
    Posts
    2,402
    just tested this:

    http://yaab-arduino.blogspot.com/201...log-input.html

    using interrupt driven input gives you much faster sampling and you can multitask (the processor is still available while the ADC is processing, the analogRead() function just blocks until it's finished)

    actually dont think i'll need it, but for other projects, will come in handy to be able to sample at much higher rates.

Similar Threads

  1. Segment Swaps
    By mecanicman in forum OBDII Tuning
    Replies: 4
    Last Post: 01-05-2017, 11:40 AM
  2. 4L60E --> 4L80 segment swap question
    By mekkis in forum TunerCat OBDII
    Replies: 2
    Last Post: 06-13-2016, 02:20 PM
  3. Replies: 2
    Last Post: 04-01-2015, 10:42 PM
  4. Looking for file/trans segment from 96 suburban.
    By Playtoy_18 in forum TunerCat OBDII
    Replies: 3
    Last Post: 06-06-2014, 02:09 PM
  5. $0D transmission segment swap?
    By EagleMark in forum GM EFI Systems
    Replies: 6
    Last Post: 10-10-2013, 09:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •