integrating accelerometer with Psoc development kit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

hi all,

i am relatively new to Psoc development pardon my ignorance.
i am currently working on integrating accelerometer with the development kit.

i found an article on
http://www.cypress.com/?docID=19786

after consulting an expert, he noted to me that the application note i had referred is for connecting an Accelerometer to PSoC1 devices which have SAR and ADCINC incremental ADCs. PSoC3 does not have a SAR8 user module. Instead i can use the ideas proposed in the application note but substitute the ADC with the Deltasigma ADC from PSoC.

my doubts was the figure 3 of the block diagram of accelerometer with PSoC. the control software block does it co response to PSoC3's control register? same goes to the I2C block can it be replace by the component using the PSoC creator IDE?
as there is not a direct info on how i can edit the value of the blocks, i hope to get some kind expertise's advice on how about i can cont to work on this article.

any help will be greatly appreciated.

0 Likes
44 Replies
markgsaunders
Employee
Employee
50 sign-ins 10 solutions authored 5 solutions authored

I think you need an example on using the ADC on PSoC 3. There are a few around that you can run on the development board...

Simple ADC Example - http://www.cypress.com/?rID=38629

ADC Channel Scan with Software - http://www.cypress.com/?rID=38799

Also, although I do not think you have the hardware, you could look at the projects that come with the FirstTouch kit. That kit has a Kionix accelerometer on-board and several of the kit examples use it extensively.

CY8CKIT-003 PSoC® 3 FirstTouchtm Starter Kit - http://www.cypress.com/?rID=38235

-- mgs

0 Likes
Anonymous
Not applicable

Hi yfs,

thanks for the information.
i did notice that PSoC 3 FirstTouch Starter Kit has an accelerometer on it, however i had already bought the PSoC development kit, thus have no choice but to use the kit.

i am having quite a problem as i do not understand the differences in of the two.
is there some reference i can look into to so call "convert" the methodology use in the article (http://www.cypress.com/?docID=19786) to used in the PSoC creator and PSoC development kit?

thanks.

0 Likes
MR_41
Employee
Employee
First like received
        Here is an example project that runs on the first touch kit that measures the X axis from the accelerometer. You can easily modify the project to scan all the X, Y and Z axes.   
0 Likes
Anonymous
Not applicable
        Hi Ganesh,   
   
is really nice of you to post this example project.   
is there any documentation of this project i can refer to?   
however it is using the on board accelerometer of first touch kit, which for me i may need to purchase a separate accelerometer and mount onto the breadboard of PSoC development kit?   
   
   
by the way, i am still quite stuck to the article on my first post, as is really had to "convert" over to PsoC creator software.   
furthermore i have been trying to tes out the ADC to LCD sample project that comes with the Creator software, it seems that my component bar is giving me problem,previous i could not find "ports and pins folder" thus i went to give an update to Creator 1.0.4beta, but certain components are gone again from the list after the update. i clearly remember the previous list was 84 components, now left with 64. now i am able to find "ports and pins folder" but the "digital port" under "system" is no longer there.   
   
please advise.   
   
thanks in advance for the help..   
0 Likes
MR_41
Employee
Employee
First like received
        Yes. You will have to get an accelerometer, assemble it on a SMD to DIP convertor or General Purpose PCB and fix it to the bred board area of the CY8CKIT-001. Also, the Application note is for PSoC1 family and hence cannot be directly ported to PSoC3. Instead, you will have to take the concept and use the components available in PSoC3 to create the project.   
   
You can find the documentation for the attached project in the PSoC First Touch user guide available from the below link.   
   
    http://www.cypress.com/?rID=38235    
   
There have been some upgrades to components in the latest version of PSoC Creator. The digital port component is now replaced by the Digital Output Pin and Digital Input pin components. Also, you can view older components by enabling the "Show Hidden Components" option in the Tools >> Options menu, Design Entry >> Component Catalog option.   
0 Likes
markgsaunders
Employee
Employee
50 sign-ins 10 solutions authored 5 solutions authored
        Just wanted to confirm that Ganesh is right about nothing going away. We just hid the ports component because Pins are more flexible and what we will be maintaining going forward. I strongly recommend moving to Pins and apologize that you got a little caught by our "beta" status!   
   
The board you have is much more flexible that the FirstTouch kit. One option you have is to get a Kionix SC-7 eval board and plug it straight into the DVK bread board area. All you then to do is wire up the digital control lines and analog accelerometer input to the PSoC pins. Then take the FirstTouch examples (which use the Kionix part), move the pins to the ones you have chosen, and rebuild.   
   
-- mgs   
0 Likes
Anonymous
Not applicable
        thanks ganesh and yfs for the great info.   
   
i am purchasing a similar accelerometer(    http://sgbotic.com/index.php?t...ts&product_id=440) to integrate on the PSoC development board.   
   
Pardon my ignorance of the software knowledge, i was wondering from the concept of the article and the bubblelevel example,   
   
1)since now the accelerometer i am using is 3axis should i follow the concept of the article, by using a mux? or sholud i use 3 individual ADC to read from each x,y and z?   
as the x,y,z value from the accelerometer will be available for the ADC to read at the same time.   
   
this lead to next question   
2) if i was to use a mUX,there is two mux available in the creator software, i was thinking of using the AMUXSeq, as i need to differential x,y and z value.   
is this a better choice out of the two?   
   
3) since PSoC development board had its own LCD, from the article, i can remove the concept of I2C to display on the external device right?   
however can the LCD display simultaneously 3 values by writing at the appropriate position of the LCD(ie i send to print string of x,y and z value at different position of the LCD)?   
as the LCD is only one port, can it take in 3 functions to write at the same time?   
   
or should i set the values of x,y,z in some buffer and display at one time?   
   
4)can i also remove the concept of the control unit in the article?   
as i will always on the accelerometer.   
   
any help will be greatly appreciated.   
thanks alot.   
0 Likes
MR_41
Employee
Employee
First like received

You can have only one ADC in PSoC3. You will have to use a mux to multiplex the X,Y and Z axes. The following example project (as yfs pointed out) shows how to measure multiple ADC inputs.

ADC Channel Scan with Software - http://www.cypress.com/?rID=38799

You can use the LCD_Position function to place the LCD cursor at any location and print the string you desire. You can convert the hex value from the ADC to decimal using the sprintf function and store the ascii string to a char array. Then use the LCD_PrintString function to print the ascii value at the desired location. You could set LCD Position to (0,0) and print X, (0,8) and print Y and (1,0) and print Z.

I have shown the code to print the decimal value using sprintf and LCD_PrintString in my below video.

http://www.youtube.com/watch?v=U21vjhzCJ0A

0 Likes
Anonymous
Not applicable
        Hi Ganesh,   
   
thanks for the wonderful piece of reference.   
   
i will test it out and share the result with all.   
   
cheers.   
0 Likes
Anonymous
Not applicable

Hi all,
i tested with the adxl335 accelerometer.

i make use of the example program which ganesh had provided for me.
i remove the two VDC8 module and replace them with analog pins.
i remove the 2 switches modules.

i edited the codes as i do not required the 2 switch interrupts.
i set channel 1 as P0_1, channel 2 as P0_2 and channel 3 as P0_3.
i connected my accelerometer at the respective x,y,z to P0_3,P02,P0_1.
i connect all the ground together inclusive of the accelerometer's ground, in order to make a common ground.
i set the VCC of the accelerometer to connect to the development's board's 3.3V pin.

however, there is no value being display on the LCD.
it display all 00 for the value of x,y and z.

code:
#include          
uint8 iAdcValue[3];     
void main()     
{     
uint8 iChannel=0;     
     
LCD_Start();     
LCD_Position(1,0);     
LCD_PrintString("Z Y X");     
LCD_Position(0,0);     
     
AMuxSeq_1_Start();     
AMuxSeq_1_Next();     
     
ADC_DelSig_1_Start();     
     
     
for(;     
{     
ADC_DelSig_1_StartConvert();     
LCD_Position(iChannel/4,((4*iChannel)%16));     
LCD_PrintInt8(iAdcValue[iChannel]);     
iChannel=(iChannel+1)%3;     
}     
}     
     
any advise will be greatly appreciated.     
thanks in advance.    

0 Likes
MR_41
Employee
Employee
First like received

The example project reads the ADC result and changes the channel inside the ADC's ISR (see ADC_Delsig_1_IRQ.c file, ADC_DelSig_1_IRQ_Interrupt function.

In your project, you are not enabling the ADC interrupt and there is no code to change the channels or read the results in the foreground process. So, the result will always be zero. Do the following:

1. Remove the StartConvert function call from the for(; loop.
2. Enable the ADC ISR
3. Make sure that the code to stop ADC, read ADC result, change channel and StartConvert is inside the ADC's ISR.
4. When the channel switching is done inside the ADC's ISR, you need to only update the LCD display in the for(; loop.

My suggestion would be use the ADC channel scan project as it is and only remove the DACs and connect the analog pins to the Mux. You can also remove the code that starts the DACs and isr_1 and isr_2 in main.c.

0 Likes
Anonymous
Not applicable
        Hi ganesh, it works.   
   
really thanks for the all help and information.   
   
what i did was to follow your instructions, remove the DACs and connect the analog pins to the Mux and also remove the code that starts the DACs and isr_1 and isr_2 in main.c.   
   
and it works perfectly.   
   
thanks alot.   
0 Likes
Anonymous
Not applicable
        Hi ganesh, i was reading through the codes of the ADC scanning project.   
thus i was trying to reverse engineer it as i like to learn how is it coded to scan through the ports of the MUX.   
   
however i realize that only after i built the project then the ADC_DelSig_1_INT.c plus the rest of the files are created. is that the way to generate the files?   
   
can i say that the files which i need to pay attention to beside the main.c,   
are:   
   
1.   
ADC_DelSig_1_INT.c ==> as ADC_DelSig_1.c and ADC_DelSig_1.h are normal generated module files   
   
2.   
ADC_DelSig_1_IRQ.c ==> as ADC_DelSig_1_IRQ.h is normal generated module files   
   
3.   
ADC_DelSig_1_theACLK.c   
   
is these the files which are modified to read in proper scanning of the mux?   
   
once again thanks in advance for any help.   
0 Likes
MR_41
Employee
Employee
First like received
        Yes. The library files for the components are generated by the Creator. You will have to first do a build to get these files generated. Write your interrupt code in between the "#START..." and "#END" lines inside the ADC_Delsig_1_IRQ_Interrupt function in the ADC_Delsig_1_IRQ.c file. During successive builds, when the library files are generated, the code that you write within the "START" and "END" markers will be preserved.   
0 Likes
Anonymous
Not applicable
        Hi ganesh, sincerely thanks for sharing your knowledge, it really benefit me alot.   
   
now if i like to display the values of x,y,z through the serial ports of the development boards to probably a PC hyperterm or even write to a file and saved into the PC, what is the necessary steps i have to do?   
   
thanks in advance.   
0 Likes
MR_41
Employee
Employee
First like received
        You can do this by using the UART component. You can find an example project for UART in the below web page.   
   
    http://www.cypress.com/?id=2232&rtID=113    
   
The page also has example projects for various other features of the PSoC3.   
0 Likes
Anonymous
Not applicable
        Hi ganesh,   
   
i have done using the UART.   
   
is it possible to transmit(force) the hex value as a char using the serial?   
   
i was trying to use strcat() to combine all the x,y,z value.   
   
code:   
char zout[6];   
sprintf(zout,"%x",iAdcValue[0]);   
UART_1_PutStringConst(zout);   
   
with the codes above it seems to be giving me some funny characters.   
and is it possible to clear the previous content of zout before i read the new value and send out again?   
   
however was wondering can i send in this manner of "z:FF,y:FF,x:FF"?   
   
thanks.   
0 Likes
MR_41
Employee
Employee
First like received
        The sprintf function call looks fine. Use UART_1_PutString to print the string. What is the PutStringConst function? I dont see it in the data sheet. Also, you can send labels like this:   
   
UART_1_PutString("z:");   
sprintf(zout,"%x",iAdcValue[0]);   
UART_1_PutString(zout);   
UART_1_PutString(", y:");   
sprintf(zout,"%x",iAdcValue[1]);   
UART_1_PutString(zout);   
UART_1_PutString(", x:");   
sprintf(zout,"%x",iAdcValue[1]);   
UART_1_PutString(zout);   
0 Likes
Anonymous
Not applicable
        hi ganesh,   
   
PutStringConst function comes from the UART example project function, iwas quite shock also that the function works although there is no such function listed in the data sheet.   
   
i was thinking is there a way to send out the char array as a whole array?   
as in this manner of of "z:FF,y:FF,x:FF"?   
   
thanks.   
0 Likes
MR_41
Employee
Employee
First like received
        Not sure how to create a single formatted string with labels and values. There should be string functions to do this. Needs some exploration.   
0 Likes
Anonymous
Not applicable
        hi all,furthermore is it possible o slow down the scanning rate of the mux?   
as in maybe scan every 1 or 2 sec?   
0 Likes
MR_41
Employee
Employee
First like received
        In the example project I pointed out, the input to the ADC is changed inside the ADC's ISR. So, the scanning would happen at the speed of the ADC. If you were to change the input to the ADC in the foreground and wait for conversion, then you will have control on the scan rate. You may have to drop some ADC samples if you change the inputs in the foreground. I will check this and get back to you.   
   
But you can also let the ADC scan happen at the ADC's scan rate, but read the ADC results in the foreground once in a second or two.   
0 Likes
Anonymous
Not applicable
        Hi ganesh,   
   
i am facing some problems when i increase the resolution of the ADC.   
i wish to change the ADC resolution to 16bits.   
   
changes i made to the default ADC scanning example project:   
-change the ADC resolution to 16bits.   
-change the voltage reference tp 2times which now is 2.048V.   
-change the ADC_DelSig_1_IRQ.c files, under the function   
   
"CY_ISR(ADC_DelSig_1_IRQ_Interrupt)"   
   
iAdcValue[iIndex]=ADC_DelSig_1_GetResult8(); to iAdcValue[iIndex]=ADC_DelSig_1_GetResult32(); ==> cause the data sheet indicated that if i use 16 it will return me signed 16bit result.   
   
-change the LCD display in main.c   
LCD_PrintInt8(iAdcValue[iChannel]); to   
LCD_PrintInt16(iAdcValue[iChannel]);   
   
however the result i got was only the last two hex number being display.   
eg 00ab.   
   
thus i use a hyperterm to check the output,   
it always show as:   
__20;   
   
eg aa20;   
bb20;   
   
which the "20" is always attach at the back.   
   
previous when i use the 8bit ADC, and when it send out through the serial port using UART, the value show on the hyperterminal something like:   
__1f   
   
eg aa1f;   
bb1f;   
   
there is always a 1f attached to the back of the 2hex value?   
   
any advice what should i do to see the correct value for the 16bit ADC?   
please help. thanks.   
0 Likes
Anonymous
Not applicable

I see that when your iAdcValue variable was a 8 bit variable. Are you sure you upgraded its size to 32 bit to taking the 32 bit ADC_result?

0 Likes
Anonymous
Not applicable

 How do i interface accelerometer ADXL345 to PSoc 5???

0 Likes
Anonymous
Not applicable

I have been given a task of  interfacing the accelerometer ADXL 345 to PSoc5....But there is no one to guide me.....I have problems in writing code for it....n also would like to know how to interface it.....Pls do help me!!!!

   

The Kit used is CY8C55

0 Likes
Anonymous
Not applicable

 Hello there ! Interfacing ADXL345 to PSoC5 is possible via I2C interface. Do you already know about I2C interface ? If not open the I2C component datasheet to get to know the PSoC side of things. And as far as ADXL345 is concerned, please go through the datasheet to understand various parameters, the datasheet is the best possible tutor. Your first task should be getting data in to PSoC from ADXL345, integrating the data comes later.

0 Likes
Anonymous
Not applicable

I am using SPI interfacing and i have studied about SPI using its datasheet....And I have gone through parameters of ADXL 345......I would like to know whether there is a need of using analog device development board with ADXL345 for interface or just the sensor?? And i also have problem in writing the code for it??

0 Likes
Anonymous
Not applicable

Yes, you can use SPI to interface ADXL345 with PSoC3/PSoC5 device. You do not need any analog devices board for this. All you need is PSoC5  interfaced with ADXL345 via SPI bus. Have you installed PSoC Creator ? that would be the first step towards coding. You can download the latest version of Creator from here, http://www.cypress.com/?id=2494. I believe you already have a CY8CKit-001.

   

Please also check this page for basic tutorial on getting started with PSoC3, http://www.cypress.com/?id=2232&tabID=38386 . Once you are quite familiar with the PSoC Creator environment

0 Likes
Anonymous
Not applicable

 Yes....I have the PSoc Creator 2.0.... n i have built 2 programs on LED blinking both using firmware and using clock....also i have built a code on using it as voltmeter using tutorial video.....what is the next step i can do??

0 Likes
Anonymous
Not applicable

Great. Next... place an SPI component on the TopDesign (I assume you know what is Topdesign, if not ask us). You can find the SPI component in the DIGITAL -->COMMUNICATION COMPONENTS folder in the COMPONENT CATALOG. Open the datasheet and try to understand the basics of SPI component. Now right clock the component and click on "Find Example Project(code)". PSoC Creator will now find you an SPI code example. Go through this code and understand how it works. If you get past this stage, them next step is connecting PSoC to ADXL345. Do you have it already with you ? If yes in what form? Are the pins of ADXL345 accesible ?

0 Likes
Anonymous
Not applicable

 Thanku.....I ll go through it as soon as possible.....And I will let u know about the pins of ADXL 345

0 Likes
Anonymous
Not applicable

 I went through the code of example project on SPI.....I understood about the moving of data between Master & Slave....And the ADXL 345 pins r soldered on to the PCB....So i guess its not accessible.....What is the next step I can do??

0 Likes
Anonymous
Not applicable

  I went through the code of example project on SPI.....I understood about the moving of data between Master & Slave....And the ADXL 345 pins r soldered on to the PCB....So i guess its not accessible.....What is the next step I can do??

   


 

                                    
 
0 Likes
Anonymous
Not applicable

Hi vineeths_04,

   

 

   

Are there pin outs on the board which will let you access the ADXL345 pins?

   

You must have access to the SPI communication lines, SCL, SDI, SDO, CS in order to communicate with the device.

0 Likes
Anonymous
Not applicable

 yess....i do have access to those pins

0 Likes
Anonymous
Not applicable

That's great !

   

Next you need to refer to the datasheet of ADXL345 to understand which registers you need to write to configure the mode of operation of the accelerometer. You can set the resolution and range using these registers.

   

You have to connect the SCL, SDI, SDO and CS pins of ADXL345 with that of PSoC. Write the necessary commands to configure the accelerometer and then read the X, Y and Z axis registers to get the acceleration values.

0 Likes
Anonymous
Not applicable

How do you control th ss pin? how to read data in a multibyte mode?

0 Likes
Anonymous
Not applicable

 SS(if you meant Slave select) line can be selected by using a dedicated pin that can be connected to the CS pin of the ADXL345. The CS line can be driven low by writing in the firmware before initiaiting any SPI transaction.

0 Likes