I am setting up a 120 volt sequencing program to switch between 3 2000 watt heaters on one 20 amp circuit. I am using an allegromicro hall effect device that will generate a 60 cycle AC voltage with a maximum of 2.5VAC Peak to Peak ( I tested a 1200 watt hot air gun that gave me 1.4 so I assume 2000 watts will be about 2.5 maximum.
I am attempting to use the ADC on a tiny45 to read the voltage levels. Not being very smart when it comes to sine waves I think the maximum positive voltage should then be 1.25V and the negative value would be -1.25V.
I have attached the code generated by codevision but I am at a loss as to starting the conversion, I understand the interrupt will store the value when it is finished.
The Help says
If the automatic inputs scanning is disabled, then a single analog-digital conversion can be executed using the function:
unsigned int read_adc(unsigned char adc_input)
Does this function just turn on ADEN in ADCSRA? Is there a library to link in? I am lost here.
Two other questions, The output of the allegro device I have used a 220 ohm resistor, do I need to clamp the negative voltage on the ADC pin with a diode to ground?
I have selected 500.00 kHZ in codevision for the ADC clock. is it correct than that a single conversion will take 13.5 clocks so it will be able to process 37,037 samples per second? Processor is using 8mhz internal with /8 fuse.
The plan is to turn on a heater, check for a full second if the heater goes on by reading the adc values and finding the on condition to have values above 128 in the adc return value. The heater will be allowed to be on for up to 10 seconds and then the next heater will be enabled after shutting the current one down.
Here is a link to the initial questions I had on current transformers and a pic of what I am working on.
https://www.avrfreaks.net/index.p...
All comments welcome.
Edit, I just realized because of the peak to peak that 1.25 will be my maximum so I should change the ADC REF to the 1.1V ref.
I also see I only need to turn on ADSC to start and the ADIE to enable the interrupt.
[/code]