out putting binary from arduino/pic/etc - Page 1
Forum section: electronics / general

author: croyleje
author_rank: Regular Contributor
timestamp: June 02, 2012, 08:19:47 am
content: sorry if this is a stupid question but can someone let me know if my thinking is right about this. basically all micros store there assigned constant or variable values as binary correct? so i can just preform simple math operations within my program then simple shift out or bit bang that value out with out having to convert it into a binary first correct? iam working with a simple 12 bit DAC and iam getting some output but its not close the what i thought it would be i believe it is spill over from excess bits sent then stored and when i send data again it picks up where it left off adding those excess bits in and just getting worse and worse with each cycle?really just wondering if my math is right any help would be great thanks

author: MikeK
author_rank: Super Contributor
timestamp: June 02, 2012, 10:37:07 am
content: It all depends on your compiler and how you're "outputting" it. Post your code.

author: Jovian
author_rank: Contributor
timestamp: June 02, 2012, 10:44:50 am
content: Hello croyleje,From the sounds of it you already have some code written and a circuit set up. Could you post that to help us help you?Yes, all microcontrollers use binary to represent the data they store/operate on.To your second question about how to push out this data to a pin on the device; it is dependant on what programming language you are using. If you are using Assembly then this is very simple; however, if it is BASIC or C then you must take care to prevent the programming language doing anything "funny" to the data you wish to output.Regards,Jovian.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: June 02, 2012, 11:14:37 am
content: Quote from: croyleje on June 02, 2012, 08:19:47 amIn the long ago, I had a 'high end' computer sound card that was abandoned by it's makers and I needed to get it working on a system that did not exist when the card was manufactured. The problem was that the card would transfer samples to/from a 20 bit ADC/DAC but would report in it's registers a 24 bit word or three bytes. And more annoyingly the nibbles (four bits) were scattered all over the place in those three bytes or six if it was stereo.The solution was to feed good, clean sine waves, square waves and triangular waves into the ADC and try and generate the same on the output connected to a scope. For an arduino, I'd suggest you hard code a nice waveform and get the device to repeat it over and over while looking at the scope to see what is wrong.-facepalm-Sorry. Wow. Why did I just make that so complicated?Just hard-code all of the 12 bit 'ones' and configure a button press on the arduino to cycle through all twelve of them. And make note of each result. Eventually something in the code should jump out at you.And yes, please post us some code. Inquiring minds want to know.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 02, 2012, 11:46:44 am
content: sounds like a bits alignment problem or clock desynchronization (serial comm?). are you aware there's 2 bytes to store 12bit adc?

author: croyleje
author_rank: Regular Contributor
timestamp: June 02, 2012, 03:55:25 pm
content: thanks everyone ill post code and and circuit when i get home appreciate it