ASCII for numbers greater than 255

MrChips

Joined Oct 2, 2009
35,170
No. The UART implements a specific serial protocol.
Your MCU will pick up two separate 8 bits.
What you do with the 8 bits is entirely up to you.

I suggest you send one 8-bit byte with the most significant bit (MSB) set to zero.
Next send the second 8-bit byte with the MSB set to one.

When the pair of bytes are received, check for proper synchronization.
Then strip off 6 bits off each byte and recombine to give you 12 bits.

Then send 12 bits via SPI to your DAC.

Edit: kubeek beat me to the punch. His scheme is ok too.
 

Thread Starter

kj4g09

Joined Dec 4, 2011
29
The microcontroller can do anything you want. You send a byte over the uart, the microcontroller reads it and lets your program read that byte. No need to worry about start and stop bits, almost all micros have this solved on hardware level. Then you assemble the whole 12bit number and send it over the spi.
It will be better to send the first 7 bits in the first byte like 1xxx xxxx and then the rest 5 bits in the second byte like 000x xxxx, so that you can be sure which byte is the first byte.
Thank you.
Could you recommend a microcontroller for me which can not only do this work but also useful for a beginner like me to practice later on with a reasonable price please.
 

Thread Starter

kj4g09

Joined Dec 4, 2011
29
No. The UART implements a specific serial protocol.
Your MCU will pick up two separate 8 bits.
What you do with the 8 bits is entirely up to you.

I suggest you send one 8-bit byte with the most significant bit (MSB) set to zero.
Next send the second 8-bit byte with the MSB set to one.

When the pair of bytes are received, check for proper synchronization.
Then strip off 6 bits off each byte and recombine to give you 12 bits.

Then send 12 bits via SPI to your DAC.

Edit: kubeek beat me to the punch. His scheme is ok too.
Right, I see what you mean. It's like giving identification to each byte so they won't be confused. But I think the whole system only requires the DAC to be set once in every 5-10 mins, it won't be used frequently. It the identification method still necessary?
It's better to have such identification method anyway.
 

MrChips

Joined Oct 2, 2009
35,170
Right, I see what you mean. It's like giving identification to each byte so they won't be confused. But I think the whole system only requires the DAC to be set once in every 5-10 mins, it won't be used frequently. It the identification method still necessary?
It's better to have such identification method anyway.
Doesn't matter, Murphy's Laws will prevail. If something can go wrong it will go wrong.

What are the consequences of your DAC outputting full scale instead of a low voltage?
 

Thread Starter

kj4g09

Joined Dec 4, 2011
29
Doesn't matter, Murphy's Laws will prevail. If something can go wrong it will go wrong.

What are the consequences of your DAC outputting full scale instead of a low voltage?
Sorry I don't really understand your question.
I want to use the DAC to control the Voltage Controlled Amplifier. The DAC can output +-2.5V. But It will be mainly used in the -2.5V to 0V range.
 

MrChips

Joined Oct 2, 2009
35,170
What is the Voltage Controlled Amplifier driving?
What happens if the amplifier suddenly jumps to zero gain or full gain?
 

t06afre

Joined May 11, 2009
5,934
Is this some kind of school project? Then working with MCUs, you need a programmer unit and of course a MCU also. If this is a school project. Your school may have a programmer you can use.
 

Thread Starter

kj4g09

Joined Dec 4, 2011
29
What is the Voltage Controlled Amplifier driving?
What happens if the amplifier suddenly jumps to zero gain or full gain?
the Voltage Controlled Amplifier amplify signals from pre-amplifier, and the output is send to ADC then to PC.

the gain of the Voltage Controlled Amplifier is controlled by output of DAC, 0V gives unity gain, -V gives high gain, +V gives attenuation.

The gain will be set to 1 before signal goes into the Voltage Controlled Amplifier. If it suddenly jumps to zero, it won't damage the ADC, but if it jumps to full gain, the ADC might be damaged. If I make some restriction on the code of microcontroller to prevent the DAC from outputting very large negative voltage, Can I avoid that potential hazard?
 

Thread Starter

kj4g09

Joined Dec 4, 2011
29
Is this some kind of school project? Then working with MCUs, you need a programmer unit and of course a MCU also. If this is a school project. Your school may have a programmer you can use.
Yes, its a group project. One of my group member who's in charge of microcontroller and software is away for 5 days. I thought I can have a go. But we are not giving any programmer unit, we have to choose by our-self.
 
Top