# Arduino Forum

## Using Arduino => General Electronics => Topic started by: mrdutx on Apr 19, 2013, 06:13 am

Post by: mrdutx on Apr 19, 2013, 06:13 am
hey i read and old topic for fast analog read here http://arduino.cc/forum/index.php?PHPSESSID=2a664108e1246eeac25151f80e987a67&topic=6549.15 (http://arduino.cc/forum/index.php?PHPSESSID=2a664108e1246eeac25151f80e987a67&topic=6549.15)

i try this code on my arduino to get ac signal from transformer 50hz. but why i did not have the sinus graph instead square wave i get here (http://i10.photobucket.com/albums/a116/dutx/graph.jpg) (http://s10.photobucket.com/user/dutx/media/graph.jpg.html)

what is wrong with result?
Post by: PaulS on Apr 19, 2013, 07:37 am
Quote
what is wrong with result?

Perhaps nothing. You haven't shown any circuit or schematic or any code, though.
Post by: DVDdoug on Apr 19, 2013, 08:28 am
It looks like your voltage may be high (or your reference too low).    How much AC voltage are you feeding-in?

Remember that (with a sine wave) the peak voltage is about 1.4 times the RMS and peak-to-peak voltage is about 2.8 times RMS.   The maximum peak-to-peak voltage has to be less than 5V if you want to accurately read the waveform (without clipping).   That means your AC voltage should be less than about 1.75V RMS (with a 5V reference)

Quote
...to get ac signal from transformer 50hz.
You won't be able to read the negative AC half-cycle (unless you add some bias) and you can damage the Arduino if you feed-in negative voltages, or voltages greater than +5V.
Post by: mrdutx on Apr 19, 2013, 08:30 am
sorry ,
ok  here wat i do.. the circuit is here
(http://i10.photobucket.com/albums/a116/dutx/circuit-2.png) (http://s10.photobucket.com/user/dutx/media/circuit-2.png.html)
and the code is
Code: [Select]
`/*  Analog Input with prescale change  Reading a 1 kHz sine wave, 0 to 5 volts  Using analog 0  Results stored in memory for highest speed  using code from:  http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/11  with special thanks to jmknapp */#define FASTADC 1// defines for setting and clearing register bits#ifndef cbi#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))#endif#ifndef sbi#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))#endifint value[100];   // variable to store the value coming from the sensorint i=0;void setup() {   Serial.begin(9600) ;  int start ;  int i ;  #if FASTADC  // set prescale to 16  sbi(ADCSRA,ADPS2) ;  cbi(ADCSRA,ADPS1) ;  cbi(ADCSRA,ADPS0) ;#endif}void loop() { for (i=0;i<100;i++){  value[i]=analogRead(0);} for (i=0;i<100;i++){  Serial.println(value[i]);} Serial.println();Serial.println();Serial.println();delay(5000);  } `

now the result look like this (plot in excel )
(http://i10.photobucket.com/albums/a116/dutx/graph-1.jpg) (http://s10.photobucket.com/user/dutx/media/graph-1.jpg.html)
. what im try to do is get the sinus graph from the ac supply. how can i do that.
Post by: Grumpy_Mike on Apr 19, 2013, 09:30 am
First off that will feed -5V into the arduino which will damage it.
Next as said the peak voltage for a 12V AC signal is not 12V but 12 times 1.4

You can not get what you want with that schematic. You need to apply a 2.5 V bias to the analogue input and then AC couple into it ( use a capacitor), then change that bottom resistor to 3K3.
Post by: mrdutx on Apr 19, 2013, 10:18 am
Quote
First off that will feed -5V into the arduino which will damage it.

but i mesured with multimeter it show 5V. i set VR to 14kOhm. the out put to arduino pin is 5V Grumpy_Mike,

Quote
Next as said the peak voltage for a 12V AC signal is not 12V but 12 times 1.4

what u mean it by 12 time 1.4? is the output will be 16.8V. it not verry clear to me.
Post by: Grumpy_Mike on Apr 19, 2013, 10:26 am

Your meter measures 5V on its AC setting. That is measuring the RMS value of the voltage, it is not the peak nor is it the peak to peak reading. To get the peak reading from the RMS value you multiply it by 1.4, so yes the peak value you get from 12V AC is 16.8V.

You need to look up your basic AC theory.
Post by: AWOL on Apr 19, 2013, 10:35 am
Is this really a programming question?
Should I move this to "General Electronics"?
Post by: mrdutx on Apr 19, 2013, 10:37 am
hey no  :...sorry mike, im not arguing with u,

i see now, so what i measure is not Vp-p value..ok i will modify the circuit and see the result..thank mike  XD
Post by: mrdutx on Apr 19, 2013, 10:46 am

Is this really a programming question?
Should I move this to "General Electronics"?

yes i think this is electronic Q.
Post by: mrdutx on Apr 20, 2013, 05:36 am

Quote
First off that will feed -5V into the arduino which will damage it.

but i mesured with multimeter it show 5V. i set VR to 14kOhm. the out put to arduino pin is 5V Grumpy_Mike,

Quote
Next as said the peak voltage for a 12V AC signal is not 12V but 12 times 1.4

what u mean it by 12 time 1.4? is the output will be 16.8V. it not verry clear to me.

how to make bias to my circuit mike?