Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Comparison on Singles..
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Thu Sep 17, 2015 6:00 pm    Post subject: Comparison on Singles.. Reply with quote

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
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Thu Sep 17, 2015 6:55 pm    Post subject: Reset portc.0 Reply with quote

Should there be not a reset portc.0

You are just changing a variable now.

My 2 cents
Ben Zijlstra
Back to top
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Fri Sep 18, 2015 10:15 am    Post subject: Reply with quote

Reset will start again charging, this according to the relay points....
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 11:55 am    Post subject: Dim? Reply with quote

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
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Fri Sep 18, 2015 5:28 pm    Post subject: Reply with quote

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
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 6:17 pm    Post subject: Config adc and used microcontroller Reply with quote

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
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2133

netherlands.gif
PostPosted: Fri Sep 18, 2015 7:00 pm    Post subject: Reply with quote

and what about your stack setting?
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Fri Sep 18, 2015 7:22 pm    Post subject: Reply with quote

$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
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 7:39 pm    Post subject: Print getadc value Reply with quote

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
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 7:54 pm    Post subject: What about AVCC? Reply with quote

Is AVCC connected to VCC? On the real hardware that is.

Ben Zijlstra
Back to top
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 248
Location: D.F.

mexico.gif
PostPosted: Sat Sep 19, 2015 4:10 am    Post subject: Reply with quote

Lacking output configuration .



Code:
Config Portc = Output : C1v alias portc


 



Wink
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sat Sep 19, 2015 5:54 am    Post subject: Reply with quote

I am getting the voltage but portc.x is not switching..
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Sep 19, 2015 6:52 am    Post subject: Value c1raw? Reply with quote

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
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2133

netherlands.gif
PostPosted: Sat Sep 19, 2015 9:54 am    Post subject: Re: Comparison on Singles.. Reply with quote

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.
Code:

disable jtag
 

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sat Sep 19, 2015 5:04 pm    Post subject: Reply with quote

Do you mean JTAG has to do some thing with port switching..
regards.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum