[SOLVED] ADC result serially tranfer just like bit stream

Status
Not open for further replies.

sgreen

Junior Member level 3
Joined
Nov 15, 2012
Messages
31
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Visit site
Activity points
1,481
I would like to transfer ADC result from ADCH through a pin of Atmega32 serially just like bit stream. ADC result is got through sampling analog signal.Here i have included a block of code to get this. But it doesn't work what i want. My task is completed upto ADCH(8-bit data). If anyone has any better idea to transfer bit of ADCH through a pin serially pls share.
Code:
DDRB=0x01;
PORTB|=1<<PINB0;
PCM =ADCH;
for(unsigned int k=0;k<8;k++){
	PCM=PCM>>1;
if(0x01 & PCM==0x01)
 PORTB|=1<<PINB0;
 else PORTB &=~(1<<PINB0);}
 
Last edited by a moderator:

I'm not sure what the problem is.
First of all you try to transfer serially only the high byte of the ADC result (ADCH) but does it contain two or 8bits of the result and what is your intension 10 or 8bit?
Is ADLAR set to 1 (left alignment) or is it 0?

If you want to read the full 10bit result then use ADLAR=0 and read ADCW (or ADC).
 

What type of device is receiving the ADC data serially?

There are several synchronous and asynchronous serial protocols available, the AVR supports many with dedicated hardware peripheral modules.

The AVR offers both I2C (TWI) and SPI synchronous serial protocols, a UART for asynchronous serial and the 1-Wire protocol can be readily implement via software.

Why reinvent the wheel?

BigDog
 

'' ''

Thanks for reply. First of all it's a 8-bit result(ADCH) using ADLAR=1.In that case what kind of modification that I have to make in my code.
 

First of all it's a 8-bit result(ADCH) using ADLAR=1.In that case what kind of modification that I have to make in my code.

You still have not indicated what type of device is receiving the ADC value.

One possible issue with your current asynchronous serial method is the possibility of the receiving devices inability to sync to data transmission rate without some signalling method or encoding, e.g. start and stop bits, etc.

Without knowing the specific receiving device and its method of interpreting the data, it is difficult to advise you as to why your method is not producing the expected results.

BigDog
 

What you are currently sending is a series of 1-0 in an undefined timing , a one wire connection like this can't work.
One wire connections have a start/stop and some predefined pulse timing or there is a two wire connection where there is a clock signal.

I agree with bigdog that you already have many hardware option in an AVR to transmit data (SPI/I2C/UART) so I'm not sure why there is a need to implement a custom way.
 


The receiver is a kind of demodulator ic(CW6694) that can recover original analog signal in the field of digital communication.
 

The receiver is a kind of demodulator ic(CW6694) that can recover original analog signal in the field of digital communication.

I've come across several Conwise devices, if I remember correctly the CW669X series is a Bluetooth SCO PCM/CVSD CODEC.

Do you have the datasheet of the device?

In any event, what both Alex and I are attempting to convey is without some method of signaling/encoding, the receiver would be unable to differentiate a byte transmission of 0x00, 0x01, 0x0F or 0x7F.

From the viewpoint of the receiver, all four bytes appear to be a single transition from low to high or 0 to 1, using your code routine.

If you can provide the datasheet, we maybe able to help you formulate a method of communication with the device.

If I remember correctly the CW669X series has both an analog input and output from which a PCM signal is coded or decoded, the device can also provide a Bluetooth CVSD/SCO channel.

If you are attempting to generate a PCM signal, your code routine is on the wrong track.

Many AVRs do offer a dedicated Pulse Code Modulation (PCM) module, however in this situation you would probably be better off generating the PCM signal via software techniques.


BigDog
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…