• 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.

c code

Status
Not open for further replies.

aibelectronics

New Member
http://www.electro-tech-online.com/custompdfs/2005/10/circuit1_oscilloscope.pdf

does anyone understand how the change in time settings is accomplished in the above code? particularly the character to integer conversion part?

Regarding function main, why are the 'for' loops nested? I understand the first for loop is for sampling and the second for conversion, what does nesting them achieve.

How were samp value, 7000 and number 800 derived? Was it just arbitrary?

thanks in advance. :)
 

Megamox

New Member
If im looking at the right part, its just using the functions atoi and itoa to type cast and switch between characters and integers, and the result is assigned to the variable "times".

Megamox
 

aibelectronics

New Member
reply

thanks, the problem is in the values: case a represents multipliers from 2 to 9, case b represents multipliers from 10 to 99, how the character to integer conversion achieves that is what is a mystery.
 

Megamox

New Member
Well case a is just assigning whatever the user types in, into the the first element of 'n' and it is assigned through typecast to "times".

Case b is the same, except the user has typed 2 characters, and they are stored in the first and second elements of 'n' Now when the function atoi operates on the array n, it takes both elements into account and converts it accordingly.

Case c is the same as case a, except the result is divided by 10. (Which is because the base time is set to 10ms, and case C is invoked when the user wants to specify a time which is 5-9, so if they put in 5 for 5ms, the variable is set with 5 X unit = 5 X 10ms, so they divide by 10.

errrrrrrrrr i think thats all right.

Megamox
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top