Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Two 12Bit MAX189 ADC connected with Atmega32 reading problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
mastermindjp

Bascom Member



Joined: 18 Dec 2012
Posts: 51
Location: INDIA

india.gif
PostPosted: Thu Sep 07, 2017 12:29 pm    Post subject: Two 12Bit MAX189 ADC connected with Atmega32 reading problem Reply with quote

Hello friends,
I have been working on a project in which i am using two 12bit ADC (SPI) with atmega32, problem is out of these two first ADC is giving fine and fast results, whereas second ADC is giving result but it hangs in between. Why this is happening?? Hardware related Problem or software??
Code:
$crystal = 16000000
$hwstack = 32
$regfile = "m32def.dat"
$swstack = 10
$framesize = 40
'$baud = 9600
'$sim
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1024
Config Lcdpin = Pin , Db7 = Portc.2 , Db6 = Portc.3 , Db5 = Portc.4 , Db4 = Portc.5 , E = Portc.6 , Rs = Portc.7
Config Lcd = 20 * 4
Cursor Off Noblink
'Config Adc = Single , Prescaler = Auto
'Stop Adc
'Config Sda = Portc.1
'Config Scl = Portc.0
'Config Clock = User                                        
'Config Date = Dmy , Separator = /
'Dim _date As Byte
'Dim Ds1307w As Byte
'Dim Ds1307r As Byte
'Dim Weekday As Byte
'Ds1307w = &B11010000
'Ds1307r = &B11010001
'Declare Sub Max189
'Declare Sub L298
Ss Alias Portb.1
Ss1 Alias Portb.3
Dout Alias Pinb.2
Dout1 Alias Pind.2
Clock Alias Portb.0
'Clock1 Alias Porta.0
Config Ss = Output
Config Portd.6 = Output
Config Portd.4 = Output
Config Portd.5 = Output
Config Portd.3 = Output
'Config Pind.2 = Input
Config Pinb.4 = Input
Config Pinb.5 = Input
Config Pinb.6 = Input
Config Pinb.7 = Input
Dim V As Word , V1 As Word
'Gosub Getdatetime
'Set Ss1
Reset Ss
Waitms 5
Do
Loop Until Dout = 1
Shiftin Dout , Clock , V , 0 , 16
Shift V , Right , 4
'Lcd "V= " ; V
Set Ss
Waitms 200

Do
If Pinb.4 = 0 Then
Set Ss1
Waitms 50
Reset Ss
Waitms 5
Do
Loop Until Dout = 1
Shiftin Dout , Clock , V , 0 , 16
Shift V , Right , 4
Cls
Lcd "ADC1=" ; V
Set Ss
Waitms 50
End If
If Pinb.5 = 0 Then
Set Ss
Waitms 50
Reset Ss1
Waitms 5
Do
Loop Until Dout1 = 1
Shiftin Dout1 , Clock , V1 , 0 , 16
Shift V1 , Right , 4
Set Ss1
Cls
Lcd "ADC2=" ; V1
Waitms 100
End If
Loop

i have tested with same DOUT and CLOCK pins and different DOUT and CLOCK pins, still the same problem.
Also, when i touch or just wave my finger above the second ADC, it starts giving continuous result, but fluctuating.

Kindly provide any relevant information and guidance to the above Problem.
Thank You

Regards Smile

_________________
We are not innovating, we are just manipulating innovations done by Mother Nature.......
Back to top
View user's profile Visit poster's website
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Thu Sep 07, 2017 5:34 pm    Post subject: Reply with quote

Hi,

The only thing I can see is that your Setting SS to an Output, but you don't for SS1.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
mastermindjp

Bascom Member



Joined: 18 Dec 2012
Posts: 51
Location: INDIA

india.gif
PostPosted: Fri Sep 08, 2017 8:03 am    Post subject: Reply with quote

Hello Ian,
Thanks for the quick one, i am surprised how i missed that, its working now.


Very Happy Very Happy

thanks

Regards
Aniruddha

_________________
We are not innovating, we are just manipulating innovations done by Mother Nature.......
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions All times are GMT + 1 Hour
Page 1 of 1

 
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