A/d ic
Hello,
I am looking for an 8 bit A/D IC. Can you recommend one that uses SXb instruction set? IE, simple command to start sampling and acquire data from A/D?
thanks,
Nick
I am looking for an 8 bit A/D IC. Can you recommend one that uses SXb instruction set? IE, simple command to start sampling and acquire data from A/D?
thanks,
Nick
Comments
Post Edited (JonnyMac) : 9/29/2008 7:15:49 PM GMT
I am still trying to wrap my head around the differences between melabs Picbasic and the SXb.
I found an example for shiftin in the sxb help section. Can you walk me through what it is doing in the shiftin statements?
GET_ADC:
CS = 0 ' activate ADC0831
SHIFTIN Dpin, Cpin, MSBPOST, tmpB1\1, 4 <--what is going on here?
SHIFTIN Dpin, Cpin, MSBPOST, tmpB1, 4 <--- and here?
CS = 1 ' deactivate ADC0831
RETURN tmpB1
Nick
Post Edited (Macgman2000) : 9/28/2008 8:35:50 PM GMT
SHIFTIN Din, Clk, MSBPOST, tmpB1\9, 4
tmpB1 is a byte variable
\9 is how many bits clocked in (why 9bits, start + 8bits? why isn't there 8 other A/D channels, how do they clock in?)
4 is 4x speed (4x speed of what? not sure what the native clock rate is....still hunting for it)
Thanks again for your help.
Nick
The help file very clearly states that the default speed of SHIFTIN is 83K bits/second. You find that in the section very deceptively (wink) labeled SHIFTIN Timing.
Time to build a circuit and start experimenting -- that's how the rest learned this stuff.
Nick
what about SX/B's ANALOGIN command? The SX, two resistors, and one capacitor make a nice 8-bit ADC without the need for "talking" to an external chip.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I was thinking about using that method, but realized there may be a problem with it. The problem I forsee is a variance in resistors and capacitors. Let me explain my application. I have 4 potentiometers 8 bit 0~255. I need resistors (possibly 1%) and high quality caps. So center position on the potentiometer should correspond to 127. This may not be true across all 4 potentiometers. So maybe I force all pots mounted to a transmitter case to center position and run an internal calibration to zero out offsets upon power on. I don't know if this is going to be less time consuming....any thoughts?
Nick
I came across this page......I can probably port the code almost as is...some changes. But this should run correct?
http://maelabs.ucsd.edu/mae_ds/stamp/how/hardware/atod_page/basic_atod.html
Nick
Post Edited (JonnyMac) : 9/29/2008 7:15:15 PM GMT
Thanks for the code!! I read through it, makes perfect sense! I am going to modify it·to pack 4 bytes +header+checksum·and TX every 20ms.·I bought an old 2 stick aircraft transmitter in great shape a few weeks ago on ebay circa...1990's (didn't power up). I paid $12, I am gutting it out and keeping the pots. I will drop in my own boards with a 2.4Ghz radio. Large housing, cool analog dial, BAM! instant radio for my financially draining hobby.
Nick
one of my "early" SX projects handled reading the position of 16 potentiometers. You can find a description of this project in my book. For a recent project, I used the same method for reading 10 potentiometers. In both cases, I'm sending the "raw" pot data to a PC via RS-232 where a VB application takes care of calibrating, and normalizing such "raw" data.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Nick
Post Edited (Macgman2000) : 9/30/2008 1:05:27 AM GMT
OK, I am confused. I see in your code that ADC0838 routine return "result". Result as a variable, but nothing is done with this variable. I would think that since "result" has the 8 bit magnitude of the ADC at whatever channel 0~7 that it would be used directly. Looking at the list file I see that result is put into _PARAM1, when the func returns it puts _PARAM1 into LEDS. HELP!
Nick
It's the same, really, as doing this, but is visually neater (and clearer) and follows other languages rough construction for assigned "returned" value from functions...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I have found guides for older versions of the compiler. I can not seem to find one that tells me the basic mechanics of what is assumed, passed and why.
From your example the inference I draw is that if you return 1 value it is assumed _param1 holds this value? If it is 2 then _param1 and _param2 in some order hold the value? This is regardless of the variable name, so just calling something a variable and passing it in a SUB or FUNC sets up the _paramX passing?
Maybe I am not looking in the right places for info, I feel I am missing a good chunk of info on how the compiler works in this situation. I appreciate your help!
Nick
Yes __PARAM1 holds the first byte returned, then __PARAM2 holds the 2nd byte returned, and so on.
If a WORD variable is returned you can use the alias __WPARAM12.
FUNC's must be declared so the compiler knows how many bytes you are returning. As in:
MyFunc FUNC 2 ' A function that returns 2 bytes (1 WORD)
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
Yes __PARAM1 holds the first byte returned, then __PARAM2 holds the 2nd byte returned, and so on.
If a WORD variable is returned you can use the alias __WPARAM12.
FUNC's must be declared so the compiler knows how many bytes you are returning. As in:
MyFunc FUNC 2 ' A function that returns 2 bytes (1 WORD)
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
Nick
But since you asked... (tho' I'm not Bean)....
Values are assigned to params LSB first if a Word value, and PARAM1 is always first. When calling subs or funcs that allow for a different numbers of params, __PARAMCNT gets set with the number of params filled before calling.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
So if you have a function that returns three bytes (value1, value2, value3) you would use:
RETURN value1, value2, value3
This will automatically put value1 into __PARAM1, value2 into __PARAM2, and value3 into __PARAM3.
Then in the main program you can do:
temp1 = MyFunc ' This will put __PARAM1 into temp1
temp2 = __PARAM2
temp3 = __PARAM3
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
Thanks for clarifying this issue!!!
Is there a section in HELP that has all this stuff spelled out? I have looked through HELP and everything in it at least 3x and I have not seen anywhere that this is addressed. I looked up FUNC and SUB, brief mention only of _param. It would be nice to have a detailed nuts and bolts explanation of what goes on in the compiler. Like I said a few posts ago, am I looking at the wrong info? The only info I have is the Practical SX/B and the HELP section of the compiler...I still feel I am missing something.
Nick
Post Edited (Macgman2000) : 9/30/2008 3:46:35 PM GMT
I'm working hard to finish this -- fully updated to SX/B 2.0; I know a lot of people have been waiting a long time and I continue to appreciate your patience; I've learned the hard way that writing a big book is more difficult than writing a magazine column.
Thanks for being patient with me all! I must be suffering from tunnel vision or something. I printed out a copy this morning of practical SX/B....flipped through the pages and there staring me in the face page.98.....I need a vacation.
Nick
HELP -> SX/B Help -> DEFINITIONS -> SUBROUTINE DECLARATIONS
and
HELP -> SX/B Help -> DEFINITIONS -> FUNCTION DECLARATIONS
The function help in particular contains some good examples of checking paramcnt (number of parameters passed to a function when it is called) and multi-byte assignments back from the function.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Thanks for the info [noparse]:)[/noparse] I have plenty to read now, should be fun!
Nick