MCP3208 driving me crazy
music_martin
Posts: 6
Hi all,
I'm new to the forum and i'm having trouble with an MCP3208. It's gone crazy. I tried every possible config but i can't make it work.
I'm reading 4 of its 8 channels with a BS2.
Does anyone have any experience working with this particular ADC? There isn't much out there about BS2 and MCP3208. (I already read the manual). It is hooked up with a vibra MSIUSA sensor (already with a zener and a resistor), and when I just try 1 of the sensors I yet get data coming from all the channels.? This is what i'm doing:
ReadVibraData:
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11111 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 7:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11110 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 6:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11101 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 5:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11000 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 0:"," ",DEC bytea_piezo, CR
HIGH cspin
RETURN
Thanks
I'm new to the forum and i'm having trouble with an MCP3208. It's gone crazy. I tried every possible config but i can't make it work.
I'm reading 4 of its 8 channels with a BS2.
Does anyone have any experience working with this particular ADC? There isn't much out there about BS2 and MCP3208. (I already read the manual). It is hooked up with a vibra MSIUSA sensor (already with a zener and a resistor), and when I just try 1 of the sensors I yet get data coming from all the channels.? This is what i'm doing:
ReadVibraData:
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11111 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 7:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11110 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 6:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11101 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 5:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11000 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 0:"," ",DEC bytea_piezo, CR
HIGH cspin
RETURN
Thanks
Comments
You will have to provide ALL of you program if you expect us to be able to help you. None of the data definitions (among other things) are shown.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I'm so sorry. Here we go:
' {$STAMP BS2}
' {$PBASIC 2.5}
'A/D
clockpin CON 8
cspin CON 11
outputpin CON 10 'Din
inputpin CON 9 'Dout
bytea_piezo VAR WORD
DIRS = %1111111111111111 'all outs
OUTS = %0000000000000000 'all low
ReadVibraData:
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11111 \ 5]'lbfirst
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12] 'msbpost
DEBUG "CH 7:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11110 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12]
DEBUG "CH 6:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11101 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12] 'MSBPOST
DEBUG "CH 5:"," ",DEC bytea_piezo, CR
HIGH cspin
LOW cspin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%11000 \ 5]
SHIFTIN inputpin, clockpin, MSBPOST, [noparse][[/noparse]bytea_piezo \ 12] 'MSBPOST
DEBUG "CH 0:"," ",DEC bytea_piezo, CR
HIGH cspin
GOTO ReadVibradata
Thanks a lot for helping,
Regards,
Martin
Why are you accessing channels that you aren't using? If that's the whole problem, just don't do it - what more can I say.
The program seems fine to me, except I thought it odd that you were using CH7, CH6, CH5 and then CH0 but I guess you were just testing. The only other thing I can recommend is to make sure all of your analog and digital grounds are appropriately and separately connected.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Thanks and Best Regards,
Martin
SHIFTOUT outputpin, clockpin, LSBFIRST, [noparse][[/noparse]%00011000 \ 8].' for channel 0. That is 8 bites. It is very important to have the 3 zeroes first, t A configuration for a single-ended input like this dealing with the BS2 would be:
0
0
0
1 Single
X D2
X D1
X D0
where xxx is 000 for CH 0...111 for CH7
Hope this is helpful for someone learning how to deal with ADCs.
A good resource for grounding and other tips are these:
"Getting the Most Out of Your 12-Bit AD", Parallax
"Layout Tips for 12-Bit A/D Converter Application", Bonnie C. Baker, Microchip.
Thanks.
Martin