View previous topic :: View next topic |
Author |
Message |
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Thu Sep 17, 2015 6:00 pm Post subject: Comparison on Singles.. |
|
|
In my code I am using this..
If C1v >= 4.20 Then
Set Portc.0
C1_chg_flag = 1
Else
C1_chg_flag = 0
End If
working fine in proteus but not working in real hardware, I have tested the relays driven by ULN2803 and are working by switching the port individual pins. JTAG is disabled in the code.
Config Aci = Off ' comparator off
Mcusr = &H80 ' jtag disabled.
I have also made sure to disable jtag in programmer (USBASP) using eXtreme Burner - AVR.
regrds..
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Thu Sep 17, 2015 6:55 pm Post subject: Reset portc.0 |
|
|
Should there be not a reset portc.0
You are just changing a variable now.
My 2 cents
Ben Zijlstra |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Fri Sep 18, 2015 10:15 am Post subject: |
|
|
Reset will start again charging, this according to the relay points.... |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Fri Sep 18, 2015 11:55 am Post subject: Dim? |
|
|
If this is all the information we get I doubt if we can help you.
What about how you have dimensioned the used variables?
Ben Zijlstra |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Fri Sep 18, 2015 5:28 pm Post subject: |
|
|
Ddrc = &B11111111
Dim C1raw As Word
Dim C1v As Single
DO
C1raw = Getadc(0)
C1v = C1raw
C1v = C1v * 5 ' to adjust it according to the measured voltage on aref pin
C1v = C1v / 1024
If C1v >= 4.20 Then
Set Portc.0
End If
If C1v <4.20 Then
reset Portc.0
End If
loop
end
This is the snnipet of te code.
regards. |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Fri Sep 18, 2015 6:17 pm Post subject: Config adc and used microcontroller |
|
|
Could you show us your config adc line and what microcontroller you are using. I have put your example in the simulator and it works. The adc value should be between 860 and 861 to activate the relay.
Have you checked the adc value with a print?
Have fun
Ben Zijlstra |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Fri Sep 18, 2015 7:22 pm Post subject: |
|
|
$regfile = "m16adef.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 128
$swstack = 64
$framesize = 64
'Hardware Configuration ===============================
Config Aci = Off
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
As I said working in proteus not in Real HW.
regards |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Fri Sep 18, 2015 7:39 pm Post subject: Print getadc value |
|
|
Do you realy got a reading on getadc(0)?
Could you try a print of c1raw after the getadc(0)
Have fun
Ben Zijlstra |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Fri Sep 18, 2015 7:54 pm Post subject: What about AVCC? |
|
|
Is AVCC connected to VCC? On the real hardware that is.
Ben Zijlstra |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sat Sep 19, 2015 5:54 am Post subject: |
|
|
I am getting the voltage but portc.x is not switching.. |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Sat Sep 19, 2015 6:52 am Post subject: Value c1raw? |
|
|
Would like to see the value from the getadc(0)
Because the program is working in the simulator I would like to see the value of c1raw after the getadc(0)
I hope you connected the source to pin 40 of the atmega16a and that the grounds are connected. That the value of the source is between 0 volt and AVCC.
Ben Zijlstra |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Sat Sep 19, 2015 9:54 am Post subject: Re: Comparison on Singles.. |
|
|
naseerak wrote: |
Mcusr = &H80 ' jtag disabled.
|
That's not the correct way to disable the jtag.
You need to write the mcusr register twice within 3 clock cycles to disable the jtag.
Or easier use the bascom statement.
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sat Sep 19, 2015 5:04 pm Post subject: |
|
|
Do you mean JTAG has to do some thing with port switching..
regards. |
|
Back to top |
|
|
|