You are on page 1of 4

10/25/2016

ADS1292firmware|

Home

Luciddreamingdevice

Projects

About

ADS1292firmware
ThereareseveralregisterswhichhavetobeinitializedbeforeyoucanworkwiththeADS1292.
Thefollowingcodeshowstheseregistersandtheassociatedaddresses.
#defineADS1292_REG_DEVID0x00
#defineADS1292_REG_CONFIG10x01
#defineADS1292_REG_CONFIG20x02
#defineADS1292_REG_LOFF0x03
#defineADS1292_REG_CH1SET0x04
#defineADS1292_REG_CH2SET0x05
#defineADS1292_REG_RLD_SENS0x06
#defineADS1292_REG_LOFF_SENS0x07
#defineADS1292_REG_LOFF_STAT0x08
#defineADS1292_REG_RESP10x09
#defineADS1292_REG_RESP20x0A
#defineADS1292_REG_GPIO0x0B

Theinitializationcode.
voidADS1292_Init()
{
ADS1292_RESET=1;//Poweron
Delay_ms(500);

//stopcontinuousreadmode
ADS1292_SendCommand(ADS1292_CMD_SDATAC);

//setcontinuousconversionmode
//setsamplerateto125sps
ADS1292_WriteRegister(ADS1292_REG_CONFIG1,0b00000000);

//enableinternalreference
//setinternalreferenceto2.42v
ADS1292_WriteRegister(ADS1292_REG_CONFIG2,0b10100000);

//enablechannel1
//gainx12
//normalelectrodeinput
ADS1292_WriteRegister(ADS1292_REG_CH1SET,0b01100000);

//enablechannel2
//gainx12
//normalelectrodeinput
ADS1292_WriteRegister(ADS1292_REG_CH2SET,0b01100000);

//RLDREFsignal(AVDDAVSS)/2generatedinternally
//calibrationon
ADS1292_WriteRegister(ADS1292_REG_RESP2,0x83);

//enableRLDbuffer
ADS1292_WriteRegister(ADS1292_REG_RLD_SENS,0x20);

//inittheremainingregisterswithdefaultvalues
ADS1292_WriteRegister(ADS1292_REG_LOFF,0x10);
ADS1292_WriteRegister(ADS1292_REG_LOFF_SENS,0x00);
ADS1292_WriteRegister(ADS1292_REG_LOFF_STAT,0x00);
ADS1292_WriteRegister(ADS1292_REG_RESP1,0x02);
ADS1292_WriteRegister(ADS1292_REG_GPIO,0x00);

ADS1292_SendCommand(ADS1292_CMD_OFFSETCAL);
}

ThefollowingcodesendsacommandtotheADS1292.

https://bois083.wordpress.com/luciddreamingdevice/version50/ads1292firmware/

1/4

10/25/2016

ADS1292firmware|
voidADS1292_SendCommand(uint8command)
{
ADS1292_CS=0;

SPI_Write(command);

ADS1292_CS=1;
}

Thefollowingcodewritesavalueintothegivenregister.
voidADS1292_WriteRegister(uint8address,uint8value)
{
ADS1292_CS=0;

//writecode+address
SPI_Write(ADS1292_CMD_WREG|address);

//write1register
SPI_Write(0);

//writeregistervalue
SPI_Write(value);

ADS1292_CS=1;
}

Readingaregistercanbedonewiththefollowingcode.
uint8ADS1292_ReadRegister(uint8address)
{
uint8value;

ADS1292_CS=0;

//readcode+address
SPI_Write(ADS1292_CMD_RREG|address);

//read1register
SPI_Write(0);

//readregistervalue
value=SPI_Read(0);

ADS1292_CS=1;

returnvalue;
}

Settingthedevicetoreaddatacontinuousmodeandstarttheconversion.
voidADS1292_StartC()
{
//setdevicetoreaddatacontinuousmode
ADS1292_SendCommand(ADS1292_CMD_RDATAC);

//startconversion
ADS1292_SendCommand(ADS1292_CMD_START);
}

Stoppingtheconversion.
voidADS1292_Stop()
{
//stopconversion
ADS1292_SendCommand(ADS1292_CMD_STOP);
}

ThiscodereadsthechanneldatafromtheADS1292.
int32channelData[2];

//Channeldata(24statusbits+24bits2channels)=72bits
voidADS1292_UpdateChannelData()
{
uint8i,j,tmp;

ADS1292_CS=0;

https://bois083.wordpress.com/luciddreamingdevice/version50/ads1292firmware/

2/4

10/25/2016

ADS1292firmware|
//read3bytestatusregister(1100+LOFF_STAT[4:0]+GPIO[1:0]+13'0's)
tmp=SPI_Read(0);
tmp=SPI_Read(0);
tmp=SPI_Read(0);

for(i=0;i<2;i++)
{
channelData[i]=0;

//read24bitsofchanneldatain3bytechunks
for(j=0;j<3;j++)
{
tmp=SPI_Read(0);
channelData[i]=((channelData[i])<<8)|tmp;
}

//convert3byte2'scomplementto4byte2'scomplement
if((channelData[i]>>23)==1)
{
channelData[i]|=0xFF000000;
}
else
{
channelData[i]&=0x00FFFFFF;
}
}

ADS1292_CS=1;
}

ThisisthemaincodewhichreadsthedatafromtheADS1292andtransmitsittothePC.Ifthedataisintendedtobeusedbythe
microcontrollerthenthedigitalfilterscanbeappliedafterreadingthenewvaluestofilteroute.g.the50Hznoise.
ADS1292_Init();

while(1)
{
if(transmitOn)
{
if(ADS1292_DRDY==0)//newdataavailable
{
ADS1292_UpdateChannelData();

//sendthedatatothePC
SendByte(0xA0);//sendstartbyte
SendByte(12);//sendlengthofdatapayloadinbytes

SendBytes((uint8*)&packetCounter,4);//sendpacketcounter
SendBytes((uint8*)&channelData[0],4);//sendchannel1data
SendBytes((uint8*)&channelData[1],4);//sendchannel2data

SendByte(0xC0);//sendendbyte
}
}

//pressingthebuttonontheboardstarts/stopstheconversion
if(BTN_START==0)
{
transmitOn=!transmitOn;
if(transmitOn)
{
ADS1292_StartC();
}
else
{
ADS1292_Stop();
}

Delay_ms(1000);
}
}
}

Like
Bethefirsttolikethis.

4thoughtsonADS1292firmware

https://bois083.wordpress.com/luciddreamingdevice/version50/ads1292firmware/

3/4

10/25/2016

ADS1292firmware|

vic July12,2015at5:46pm
Thanks!
Reply

Humbert August2,2016at11:39pm
Hi,
Ifindyourprojectveryinteresting.
Couldyoupleasegivemesomeinfoaboutit?Idliketobuildit

HaveyouusedtheADS1292RorADS1292?
YouusedtheEvaluationModuleoryoubuilttheboardaswell?
Thanksinadvance,
Reply

bois083 August3,2016at7:31am
Hi,
Thanks.Pleasechecktheotherpages,thereyoucanfindmoreinfoaboutthisproject.IusedtheADS1292
andIbuildmyownboard.
Reply

FDf September17,2016at5:18am
ADS1292_CMD_START
ADS1292_CMD_RDATAC
ADS1292_CMD_STOP
Whatisit??
Reply

LeaveaReply
Enteryourcommenthere...

RecentPosts
InternetradioandmusicplayerwithESP8266
PlayingaudiofileswithCSR8645Bluetoothchip
PlayingaudiofileswithOVC3860Bluetoothchip
PlayingWAVfilesusingPWM
PlayingFLACfilesusingVS1053audiodecoderchip

https://bois083.wordpress.com/luciddreamingdevice/version50/ads1292firmware/

4/4

You might also like