Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Trying to get aquainted with programming variables in C++ !

Status
Not open for further replies.

BGAmodzX

Member
Hello everybody.

Back when i switched lanes from production process engeneering towards stuff that heavily implies applied maths like electronics , i decided to introduce myself to it by learning middle school maths specifically basic algebra. And I have successefully managed to play with physics equation in electronics.

But when i started doing programming i noticed that am still limited to stuff like electronic clocks using incrementation and decrementation variables and nothing special.

So my question is :

How can i be strong in programs that use multiple and complex variable operations ?

Note : my goal is to make projects like voltage and current digital displays.

41mkBd3Os6L._AC_.jpg
 
How can i be strong in programs that use multiple and complex variable operations ?

Note : my goal is to make projects like voltage and current digital displays.
Depending on the micro chosen C++ doesn't really feature in low / mid sized pics... There is a C++ compiler for the pic32 and for the Arduino platform..

What do you think is complex variable operations??
 
Depending on the micro chosen C++ doesn't really feature in low / mid sized pics... There is a C++ compiler for the pic32 and for the Arduino platform..

What do you think is complex variable operations??
Hi thanks for your interest.

I dont mean complex numbers but i mean the usage of variable's opetations to achieve complex digit displays used in multimeters and other similar devices.

like this one :

da23390f-2a57-47cd-b840-5b54722f219b.jpg
 
The display on the meter isn't graphical, the whole thing is bit controlled there is two 4.5 digit LCDs a bar graph and around 8 on / off symbols.

The variables for voltage and frequency would be simple integers... Very much the same for the first display you show..

I think there have been one or two simple voltmeters done here on ETO I know there is on piclist I should imagine there will be a few using AVR as well... I doubt you would need more than a 8 bit micro to achieve all of the above...

I have written calculator using the humble pic18... Not just "1+1= " sort of thing.. Full string parsing. ie:- "5 * ((5 + 6) / 19) - 45" sort of thing..
Granted! Auto ranging and the like are slightly more advanced... But should be pretty easy to do..
 
Thanks ian.
The display on the meter isn't graphical, the whole thing is bit controlled there is two 4.5 digit LCDs a bar graph and around 8 on / off symbols.

The variables for voltage and frequency would be simple integers... Very much the same for the first display you show..

I think there have been one or two simple voltmeters done here on ETO I know there is on piclist I should imagine there will be a few using AVR as well... I doubt you would need more than a 8 bit micro to achieve all of the above...

I have written calculator using the humble pic18... Not just "1+1= " sort of thing.. Full string parsing. ie:- "5 * ((5 + 6) / 19) - 45" sort of thing..
Granted! Auto ranging and the like are slightly more advanced... But should be pretty easy to do..
thanks man.
do you thing i should study some math or just stick with programming ?
 
do you thing i should study some math or just stick with programming ?
I suggest you have a go at writing a simple calculator. Programming and maths are different subjects but normally high school maths is all that's needed in most programs.

Mike.
 
I suggest you have a go at writing a simple calculator. Programming and maths are different subjects but normally high school maths is all that's needed in most programs.

Mike.
Do you think this book can be useful ? Because i have it around.

41jkzvWAFlL._SY344_BO1,204,203,200_.jpg
 
Last edited:
Like Mike said... Start small and grow..

Use a simple micro and make a simple volt meter say 0~5v Dead easy and tons of people have made one... You'll soon want to progress.

I help a guy who started really low... He now can do sooo much in a short space of time.. Make a start and
Just start writing code and when you get stuck, ask here.

Mike.
ditto!
 
Just start writing code and when you get stuck, ask here.

Mike.
Don't forget to add comments to your code as well, so you can understand clearly what it is doing if/when you refer back to it later.
 
The actual maths part on projects such as those is generally quite simple, just straightforward multiplication and division for scaling or that type of thing - it's the input and output side that take more thinking about, to get accuracy and a "nice" display.

eg. An example of the total "maths" to convert an ADC value to voltage to be displayed (copied from DrG's post in another thread) - a single line in the overall program. "sigValue" is the raw reading from the ADC, a 10 bit one hence the 1024 constant.

voltage = sigValue * (4.85 / 1024.0);


You do need to understand the number types used in programming - int, float, double, long, unsigned int etc. and when to use each, but those are based on how numbers are stored in memory, not so much maths.


You also need to be able to design and understand electronics to be able to convert the input voltages to a range that the microcontroller ADCs can accept, and rectify the input if it's to read AC etc.

And you need to build a power supply to operate those electronics and the MCU + output / display.

Ready-built PSUs or DC-DC modules are fine for experimenting and one-offs, but are often too expensive or bulky to use in mass produced items, if you are thinking along those lines.


As others say - just start experimenting and building things - if you get stuck, ask for assistance!
 
This reminded me that I showed a friend a short Basic program. With lines like C = A+B. He shuddered saying it looked like algebra. In programming, you assign values to variables. A=1, B=22, so A+B = 23. C=23 I have done great things with C++ using trigonometry to display a 3-D mesh of the ocean floor from depth soundings. No algebra needed.
 
This reminded me that I showed a friend a short Basic program. With lines like C = A+B. He shuddered saying it looked like algebra. In programming, you assign values to variables. A=1, B=22, so A+B = 23. C=23 I have done great things with C++ using trigonometry to display a 3-D mesh of the ocean floor from depth soundings. No algebra needed.
The fact is i like algebra specially playing with proofs.
Am wondering if there is programs that i can play with the same as algebra
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top