Problems with MCP3008 and ADC_INPUT_DRIVER:
MorrisMorris
Posts: 16
I'm having an issue with ADC_INPUT_DRIVER running in 10bit mode with the MCP3008. The strange thing is that my servo begins at 0 goes to 255 then skips to 768 and runs fine all the way up to 1023. So, somewhere, I think bit 9 is getting jacked. Anyone else had this problem?
Comments
first of all welcome to the propellerforum.
I'm really willing to help, but therefore I need more information. An ADC is not a device that is usually directly connected to a servo. Of course the propeller is inbetween.
But how? It might be even a MCP3208 which is a well known ADC with a driver in the obex.
Please give us (the forum-members) an overview about what you want to do in the end. If this is known much better solutions can be found.
The last couple month this forum went a little boring to me as there are not much beginner threads. Answering on newbees questions is what I personally enjoy most.
So please do me a favor and write in detail what you are doing.
Please create an archive with the propellertool.
Compile your project using F8.
Then choose from the main menu file - archive - project ... this will create a zip-archive that contains all *.spin-files that are nescessary tocompile the code
Use the "Go advanced" button and then attach the zip-archive to a posting.
best regards
Stefan
I'll post my 3008 driver in the Object Exchange when it's complete and add an update to this thread in case anyone needs it.
MCP3008.spin
I had this with my first MCP3202 driver because the interface is slightly different than with that MCP3204 and MCP3208 -- I have good drivers for all and have used them in several professional projects.
I suggest you start with a Spin driver which may be all that you need for this particular project. If you need to move to PASM, that's fine, but I always start in Spin to verify connections and behaviors before adding another layer of sophistication.
My driver includes a method called scale() which I created for converting ADC values into servo position values. The modified version works like this:
I would use a (filtered) reading from the ADC and pass my servo constraints (1000-2000, or 600-2400).
The nice thing about the MCP3208 is that it seems to be more abundant and it's better to have to chuck resolution than wish you had it. The pin-out is the same as the MCP3008, so I suppose you can try both.
It's really Parallax's. All I did was strip out the DAC parts -- so I could better understand the driver -- and reduce the number of bits the driver clocks in from 12 to 10. Glad it's working for you!
(BTW: I added it to the OBEX.)
Good to know (that I still need to test my code). I bought one of Martin's boards with the MCP3008 so I'll give the Spin version a try before moving to ObEx.