Jump to content
Sign in to follow this  
Master_Scythe

Linear voltage boost?

Recommended Posts

That's not 4-bit, that's some kind of non-standard serial connection.

 

http://www.seeedstudio.com/wiki/Grove_-_4-Digit_Display

 

Thankfully there is an Arduino library for it, so it'll be easy enough to use.

 

Also, the library looks like it can do cool stuff like variable brightness (presumably by PWM).

 

If you wanted to get your hands dirty, you could build a simple circuit with 74HCT595 shift registers, and discrete 7-seg displays.

 

Edit: Also that display is available on the local DX: http://aud.dx.com/product/0-36-led-4-digit-display-module-for-arduino-black-blue-works-with-official-arduino-boards-961254978#.VTWiHCGqpBc

Edited by SquallStrife

Share this post


Link to post
Share on other sites

Yeah but local DX charges an arm and a leg for shipping.

 

Ah forget it, I ordered from China.

$11 total (for 2x Nano V3, and 2x 4 pin displays) was too good to pass up than $40 for 1 of each locally.

 

I guess it gives me time to learn how to code them and try write some code.

Edited by Master_Scythe

Share this post


Link to post
Share on other sites

When you spend over $30.

And thats broken at the moment, it still wants you to spend over $50USD to give it free, even from the Australian store.

 

It only FREE if you leave China selected as your dispatch.

 

ordered now anyway. It'll be here in a month probably (bloody china)

Share this post


Link to post
Share on other sites

That's true. But I can always think of $30 worth of shit to buy from DX.

 

Even if it's just a reel of LED strip lighting for whatever future project.

Share this post


Link to post
Share on other sites

Yeah I got over $30 easily, but it still had almost $20 shipping. To try and spend $50 as it expected me to, would involve trying to find a spare $50, and a place for the junk :P

Share this post


Link to post
Share on other sites

 

Correct.

 

I have a wideband sensor\controller, which has a linear output of 0v to 5v, indicating a 10:1 to 20:1 AFR.

 

I've been using a normal $1 digital LCD voltage display from ebay to show the voltage between 0 and 5, and just have a sheet showing me what that would be in AFR (since its linear, thats easy).

 

But I thought, using the same display, it'd be neat if I could show actual AFR.

 

So if I could get 0~5v equaling 10~20V linearly, thats a win!

 

Ah, got it. I misinterpreted 'standard voltage meter' to be an analog dial or something that you specifically wanted to use, over a cheap LCD display.

 

If you're not attached the display you already have, using an Arduino is probably going to be simpler, and gives you the ability to customise what's sent to the display, add additional sources of information, and/or add forms of user input.

 

You're going to need the following:

 

Arduino nano or mini ($5-13) Example

Breadboard (simple, easy, not quite robust) or veroboard/prototyping PCB (requires soldering, robust) ($2-5)

Display ($3-10) LED Small LCD 1 Small LCD 2 Bigger LCD with keypad (requires bigger arduino) TFT Touch Screen (requires bigger arduino)

Jumper wires and/or solder ($3-5) Example

 

The programming required couldn't be simpler. Start here, read about ADC here, and then how to display the information here (may change depending on display chosen).

 

 

So, where should I learn about ACTUALLY programming this?

You'd be surprised about my level of knowledge. Its surprisingly broad, but sparse.

For example, I remember how to do Includes and have managed to include the library I believe my project will be using for the display.

 

However, actually coding ANYTHING beyond that? I'll need a decent and to-the-point guide; any tips? I'd like to get this finished by this weekend so I can tune my car properly with an AFR gauge :)

Share this post


Link to post
Share on other sites

Flick through the examples provided in the Arduino IDE. If you understand C syntax, Arduino should be familiar.

Share this post


Link to post
Share on other sites

about 12 years ago I understood C syntax, now, not a chance.

 

I keep finding beginners guides, where they simply show you how to do X and Y of their own project without explaining what the hell it's actually doing.

Not helpful.

 

 

I guess I'll break it down into steps:

 

1. get the LCD displaying something.

 

2. Get an 'Input' pin assigned, to read 0~5V

 

3. Make a whole bunch of 'IF' type statements, so that if input sees X volts, display Y number.

 

*sigh* Not gonna get this done by tomorrow\weekend I dont think.

Where's a good starting place? C++ for dummies? I usually enjoy the 'for dummies' writing style.

Share this post


Link to post
Share on other sites

So, where should I learn about ACTUALLY programming this?

You'd be surprised about my level of knowledge. Its surprisingly broad, but sparse.

For example, I remember how to do Includes and have managed to include the library I believe my project will be using for the display.

 

However, actually coding ANYTHING beyond that? I'll need a decent and to-the-point guide; any tips? I'd like to get this finished by this weekend so I can tune my car properly with an AFR gauge :)

 

Start with the Arduino website, and simple copy and pastes from the examples. What display do you have? If they're 7 segment LEDs, you're going to need a breadboard and some resisters to get them working. Here's a relevant tutorial. If it's an LCD, it's going to be a lot simpler, and you just need to use the appropriate library depending on whether it has a serial and parallel interface. If you can post photos or part numbers, I can help you out further.

 

With respect to step 3 in the subsequent post, there's a much easier way to do it. Scale the analog reading, add an offset for trimming, then print to display. e.g.

void setup() {
//Define variables for raw and calibrated output
int AFSensorCal;
int AFSensorRaw;
}

void main() {
// Read analog sensor value.  10-bit ADC, so 0V = 0, 5V = 1023.
AFSensorRaw = analogRead(A0);

//Scale raw reading, and apply offset
AFSensorCal = (AFSensorRaw/1023 * 20) + 0.1;

//Code to print to display type here
}

I've used a scalar of 20, and offset of 0.1 arbitrarily. Substitute 20 for what a 5V reading actually indicates, and adjust 0.1 to counter any offset in the final reading.

Edited by tastywheat

Share this post


Link to post
Share on other sites

Spot on :P 5v = 20! lol

 

and, yes, I am using 7 segment displays, but they're on a controller so I shouldnt need anything extra.

sku_254978_1.jpg

Share this post


Link to post
Share on other sites

 

void setup() {
//Define variables for raw and calibrated output
int AFSensorCal;
int AFSensorRaw;
}

void main() {
// Read analog sensor value.  10-bit ADC, so 0V = 0, 5V = 1023.
AFSensorRaw = analogRead(A0);

//Scale raw reading, and apply offset
AFSensorCal = (AFSensorRaw/1023 * 20) + 0.1;

//Code to print to display type here
}

 

Remember to...

analogReference(INTERNAL);
...before reading a value, if you're going to use the the internal voltage reference, as I described in my earlier post.

 

http://www.arduino.cc/en/Reference/AnalogReference

 

I'll also note that Arduino uses...

void loop(){ }
...not "main". Edited by SquallStrife

Share this post


Link to post
Share on other sites

 

Remember to...

analogReference(INTERNAL);

 

 

I don't have an Arduino handy to test it out, but I think the IDE is clever enough to default to internal reference if nothing is specified. It's certainly good practice to do so though.

 

With respect 'main', you're absolutely right. Goofy error on my part.

Share this post


Link to post
Share on other sites

Spot on :P 5v = 20! lol

 

and, yes, I am using 7 segment displays, but they're on a controller so I shouldnt need anything extra.

 

Looks like a seedstudio clone that operates on a TM1637. If you haven't already done so, get the latest Arduino IDE from http://www.arduino.cc. You'll want to verify your arduino is working with the basic blink sketch. Open Arduino, select File > Examples > 01.Basics > Blink. Specify that you're using a Nano using Tools > Board > Arduino Nano. Compile using Sketch > Compile, and make sure no errors come up. Plug in your Arduino, and ensure Tools > Port is looking at the right port (hit up device manager and find the arduino in your USB tree, and look at the properties to check which port it's using). Upload your sketch using Sketch > Upload, and you should see a green LED on the board blinking at around 1Hz. Report back if you have any problems.

 

Next, have a read of this page on the Arduino playground:

 

http://playground.arduino.cc/Main/TM1637

 

VCC (voltage common connector) is simply the voltage supply pin (not quite self explanatory for those unfamiliar with electronics). You'll connect this to the +5V output from your Arduino, the GND to GND, CLK to D2 and DIO to D3.

 

arduino+pinout.png

 

 

Download the library using the 'latest release' link at the bottom of that page. Follow the 'Importing a .zip Library' instructions on this page.

 

Once you've done that, open the example code using File > Examples > TM1637-1.0.0 > TM1637Test. Compile using Sketch > Compile, and make sure no errors come up. Upload your sketch using Sketch > Upload, and you should see the demo code working the display.

 

Once you get this far, let me know, and I'll guide you through getting your Arduino to read the sensor output.

Edited by tastywheat

Share this post


Link to post
Share on other sites

I don't have an Arduino handy to test it out, but I think the IDE is clever enough to default to internal reference if nothing is specified. It's certainly good practice to do so though.

For the default reference yep.

 

In my circuit earlier, I divide the measurement voltage down to 0-1V1 in order to use the internal 1V1 voltage reference. The default is to use Vcc as the reference, but this could fluctuate in the auto environment. Whereas the internal Vref is quite stable.

 

To use the internal Vref, you do need to use...

analogReference(INTERNAL);
...but you're right that it's not necessary if you don't want to use it. If you wanted to explicitly use Vcc as the analogue reference (say, after having used the Vref for something else), then you can...

analogReference(DEFAULT);
Edited by SquallStrife
  • Like 1

Share this post


Link to post
Share on other sites

 

Once you get this far, let me know, and I'll guide you through getting your Arduino to read the sensor output.

 

 

I thougth I'd throw an update here; I got really disheartened having to 'start from scratch' with my C learning.

But I thought meh, I'll just play around anyway.

 

After about 15 minutes finding the chinese drivers for the COM>USB chip that was included on those boards, I loaded BLINK and had a little rave party.

I also had a moment of (blatently obvious) intrigue at the power savings between the 'always on' power LED, and the 1ms blink, which to the human eye appears always on, and is just as bright.

 

I've added the library for my displays and tonight will get to soldering the basics.

 

I've learnt the Mini USB port can 100% substitute the +5 VCC pin for powering the arduino (very convenient, and i knew what vcc mean't :P)

So tonight I'll cut a Cat5 cable up and solder some wires. The boards came with pin headers to solder in, but I'm going for ultra low profile device, and i want an extension on the display so i can have that on the dash board, and the controller behind it. so it's hard wire time baby, yeah.

 

Also, at the low cost of this device, I know I wont be 're using it' in a hurry, once this works, I might add some features down the track, but for now, its staying as I build it.

 

 

 

One thing though,

I'm torn between your idea of using an offset and reference value like you suggest, and defining each exact voltage to a display value.

 

On one hand, your idea means perfectly accurate\linear output from 0~5v (10~20AFR on display), but that changes so rapidly it could be a bit dazzling.

On the other, I'd love to program in some safety and or smoothing, along with 'custom displays' for LEAN and RICH, which can both be spelt on the display.

 

 

I'm pretty excited to be actually doing this, it's been a long time since I learnt anything or built something (at least, outside my comfort zone, I build a lot of class AB amplifiers and customise a few class D\T).

 

I'm pretty excited.

Once it's wired up, I'll see if the 'test script' for that display works, and if it does, its time to get crackin!

 

I'm assuming I'll need to grab a 5v regulator and shed some volts? at 40mA we're looking at 0.36w of heat, which should be a tiny heatsink.

Even if it jumped up to 100mA once I added the display..... hmm what does that draw....

 

EDIT:

Current (at 5V): 30~80mA, so 55mA nominal.... lets say 60mA.

 

So, its 60mA + Nano's 40mA = 100mA of power.

 

So, lets round that 0.9w up to 1W of heat I'll need to heatsink; should be bloody simple actually. Single RamSink should do it.

Edited by Master_Scythe

Share this post


Link to post
Share on other sites

Oh, hold on:

 

"Power:
The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically selected to the highest voltage source."

 

Shall I just run 10v~15v though the unregulatoed pins?

Or do you think I'm better off not trusting my chinese knockoff (and its built in regulator) and just feeding it direct 5v regulated??

 

the $2 it costs isn't going to ruin me :P

Edited by Master_Scythe

Share this post


Link to post
Share on other sites

 

Shall I just run 10v~15v though the unregulatoed pins?

Or do you think I'm better off not trusting my chinese knockoff (and its built in regulator) and just feeding it direct 5v regulated??

 

the $2 it costs isn't going to ruin me :P

 

Using the onboard voltage regulator means there's one less variable to worry about, which is important when it comes to cheap Chinese gear that isn't always specced or assembled correctly.

 

Before soldering everything, it's worthwhile doing a test run using (ideally) a breadboard, or failing that temporary connections held in pace mechanically some way (making sure they're not able to short out). Again, the quality control of Chinese gear isn't infallible, and on more than one occasion I've had leads labeled wrong etc. If it's soldered, it's going to be harder to switch things around to check this.

 

The onboard regulator should be able to handle to displays without any issues, so there's no need to overcomplicate things with additional regulators or heatsinks. You can add them later if you want, but it's better to keep the setup as simple as possible to begin with. This way, if you hit any issues, your list of potential causes are smaller, so it's easier to resolve.

Share this post


Link to post
Share on other sites

Sorry, I wan't clear.

I meant for the overall supply voltage when I finally install it in a vehicle. (V in)

I wasnt going to try and regulate the displays power source.

 

Its not really one less variable. Its either 5v Regulated (relying on a 7805 reg), or 12~14v unregulated (relying on its on device regulator).

Either way there's a regulator at play here, its just whether or not I uprate the device by using an external one, and feeding it regulated.

 

Ive seen more than one case of chinese devices going sizzle at 15v despite the unregulated pins being rated to 20v.

 

Worth it? Or just risk it as is and 'hope it all works'.

I have two, if one failed.



Using the onboard voltage regulator means there's one less variable to worry about, which is important when it comes to cheap Chinese gear that isn't always specced or assembled correctly.

 

Before soldering everything, it's worthwhile doing a test run using (ideally) a breadboard, or failing that temporary connections held in pace mechanically some way (making sure they're not able to short out). Again, the quality control of Chinese gear isn't infallible, and on more than one occasion I've had leads labeled wrong etc. If it's soldered, it's going to be harder to switch things around to check this.

 

The onboard regulator should be able to handle to displays without any issues, so there's no need to overcomplicate things with additional regulators or heatsinks. You can add them later if you want, but it's better to keep the setup as simple as possible to begin with. This way, if you hit any issues, your list of potential causes are smaller, so it's easier to resolve.

 

Edited by Master_Scythe

Share this post


Link to post
Share on other sites

Yup, I meant Vin as well, though I probably should have been more specific and specially mentioned the regulator onboard the arduino connected to Vin.

 

Every electrical connection is a point of failure and uncertainty, so if the onboard regulator can handle the load without issue (it should) there's less of an incentive to upgrade.

 

However, one thing the previous post didn't take into account (mostly because I wasn't paying proper attention) is that you'll be connecting it to a car. In that case, a seperate voltage regular capable of handling up to at least 24V is probably a good idea.

Share this post


Link to post
Share on other sites

Yup, I meant Vin as well, though I probably should have been more specific and specially mentioned the regulator onboard the arduino connected to Vin.

 

Every electrical connection is a point of failure and uncertainty, so if the onboard regulator can handle the load without issue (it should) there's less of an incentive to upgrade.

 

However, one thing the previous post didn't take into account (mostly because I wasn't paying proper attention) is that you'll be connecting it to a car. In that case, a seperate voltage regular capable of handling up to at least 24V is probably a good idea.

 

 

ok, done I'll grab a 5v regulator and use the regulated input. 1W of heat should be easy to manage.

 

Also, my display is now working with the test script!

Share this post


Link to post
Share on other sites

On the other, I'd love to program in some safety and or smoothing, along with 'custom displays' for LEAN and RICH, which can both be spelt on the display.

Since you're using a serially driven display, you have heaps of pins free for other stuff. You could have a slider switch that toggles between numeric and rich/lean. Also there are more ADC pins, so you could have a knob for adjusting brightness, or frequency of updates.

Share this post


Link to post
Share on other sites

Brightness would be cool.....

Exhaust Temp would also be VERY cool (another sensor with voltage output).

Intake air temp..... the list goes on.

I'm no where near having a button press change screens :P

 

I'm having a really hard time getting my head around this.

Now I remember why I had such trouble with C++.

It DOES click eventually, but my minds been out of that thought process for so long.

You'll know when it clicks, because you'll see stupid ammounts of code examples while i brainstorm thigns :P

 

My mind is actually quite good with thinking in a 'programming way', python (years ago) was easy, and HTML already has the 'layout' covered, so my mind can focus on that and 'modify it' with code.

And unfortunately, that's where i'm getting stuck with C code.

 

I give you my word that I'm not just trying to get "someone to do the work for me", I'm genuinely having a hard time getting started.

 

So just like normal C, adding a library means I can now use its 'commands', I get that, thats simple.

I can assign the correct pins to the display, and clearly thats working. That stuff can go in the 'setup' section.

 

I can even assign (i think....) a pin to read the analogue voltage I'm after (but i'm sure my context is wrong).

 

Where my mind gets stuck is trying to make the relevant connections between my read variable, and the screen.

 

My logical brain wont bugger off and let programming take over; I'm thinking in some wired form of BASIC and SQL or something.

I know what I'll need at the end is basically;

IF VoltageInput EQUALS 1.0v PRINT 12.0

IF VoltageInput EQUALS 5.0v PRINT 20.0

and everything in between.

 

So somethign like;

 

(missing my includes, since I'm at work)

void setup() {
//Define my Screen pins, but I'm at work :P

 

 

//Define variables
int VoltageInput;
}

void loop() {
// Read Input
VoltageInput = analogRead(A0);

 

 

So, I'm reading a voltage and storing it in 'VoltageInput', how do I do 'IF' type commands in C, and link it to the display output?

I've decided that, although the 'Calculated' output is a great idea, and probably 'better programming' I'd like to define each value for now.

 

Yep I feel like an idiot, but I'm learning, I just need to use a technique that I havent learnt yet. I'm sure my 'For Dummies' books and online guides will get there :)

 

Thanks everyone you're all great :)

Edited by Master_Scythe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×