View previous topic :: View next topic |
Author |
Message |
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Tue Jan 05, 2021 3:35 am Post subject: |
|
|
Printpix52 wrote: | JP1 at 12 volts? Feed yourself with 5 volts. |
IC2 is a 5 volt regulator |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Tue Jan 05, 2021 3:36 am Post subject: |
|
|
Printpix52 wrote: | In the schematic representation we can see that the fixed terminals are 1 and 2, while the cursor is the number 3, which is represented by an arrow. |
I don't follow |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jan 05, 2021 3:37 am Post subject: |
|
|
KenHorse wrote: | Printpix52 wrote: | JP1 at 12 volts? Feed yourself with 5 volts. |
IC2 is a 5 volt regulator |
Yes. |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jan 05, 2021 3:41 am Post subject: |
|
|
How are you connected outside JP1? |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jan 05, 2021 3:44 am Post subject: |
|
|
KenHorse wrote: | Schematic |
Is it a battery charger? what do you use this circuit for? |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Tue Jan 05, 2021 3:45 am Post subject: |
|
|
When the voltage drops below "29", de-activate a relay. When it rises above, activate the relay |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jan 05, 2021 3:52 am Post subject: |
|
|
KenHorse wrote: | When the voltage drops below "29", de-activate a relay. When it rises above, activate the relay |
Yes, the maximum ADC input voltage is 5 volts. |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jan 05, 2021 3:56 am Post subject: |
|
|
Code: | Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc |
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Tue Jan 05, 2021 4:55 am Post subject: |
|
|
Hi,
Pin 1 (ADC0) is a RESET pin, so unless you change the fuse settings, it will reset at the [L] level.
If the voltage is higher than the reset level, it will function as ADC0.
It works if you change it to pin 2 (ADC3).
Also, when outputting to a port, it is Portb.0 instead of Pinb.0.
Code: | $regfile = "attiny13.dat"
$hwstack = 10
$swstack = 10
$framesize = 16
$crystal = 1200000
Relay Alias Portb.0
Config Relay = Output
Const True = 1
Const False = 0
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start ADC
Relay = False
Do
If Getadc(3) < 29 Then
Relay = True 'energize
Else
Relay = False 'de-energize
End If
Loop
End |
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
Micha
Joined: 03 Oct 2006 Posts: 57
|
Posted: Thu Jan 07, 2021 6:34 am Post subject: |
|
|
You need to set:
$Crystal = ?
and
Config ADC = ... , Reference = ? |
|
Back to top |
|
|
|