- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
i am relatively new to Psoc development pardon my ignorance.
i am working on integrating accelerometer with the development kit.
after consulting several experts' advice from this forum, my setup was working quite fine. however i met with some issue about the conversion from 8bit to 16 bit of the ADC use.
sample project which i use to reference,
1) ADC Channel Scan with Software - http://www.cypress.com/?rID=38799
2) UART sample project- http://www.cypress.com/?id=2232&rtID=113
code:
char OutputString[36];
char zout[10];
char yout[10];
char xout[10];
sprintf(zout,"%x",iAdcValue[0]);
sprintf(yout,"%x",iAdcValue[1]);
sprintf(xout,"%x",iAdcValue[2]);
strcat(OutputString,zout);
strcat(OutputString,"y:");
strcat(OutputString,yout);
strcat(OutputString,"x:");
strcat(OutputString,xout);
strcat(OutputString,"@");//to indicate end of one set of conversion
UART_1_PutString(OutputString);
as the ADC channel scan is working with a 8bit ADC, i tried to setup the project and it looks ok when it display on the LCD and hyperterm.
however there is a slight issue when it display on the hyperterm, the value of what i see from the LCD and the hyperterm tally, but when it send out through the serial port using UART, the value show on the hyperterminal something like:
eg z:aa1fy:bb1fx:cc1f;
there is always a 1f follow behind each value.
next,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 to 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.
i cant print out properly on the LCD screen as i do not really catch the below method of displaying
LCD_Position(iChannel/4,((4*iChannel)%16));
LCD_PrintInt16(iAdcValue[iChannel]);
iChannel=(iChannel+1)%3;
thus i use a hyperterm to check the output,
it always show as:
eg z:aa20y:bb20x:cc20;
now there is always a 20 follow behind each value.
i was wondering why it never return me a 4 hex value?
why there is either 1f tag behind each value of the 8bit ADC output, and 20 tag behind the 16bit output?
please help.
any help will be greatly appreciated.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks alot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have been trying to modified the codes but i am still getting the wrong results.
please advise.
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have not used the interrupt method to switch channels, but am doing this in the foreground. Now, you have control regarding when to scan the channels by calling the ScanChannels function. Below is the sample of what gets printed in HyperTerminal.
X: F22F 1.937; Y: 362D 0.433; Z: 112F 0.137
X: F22F 1.937; Y: 362E 0.433; Z: 1130 0.138
X: F22C 1.937; Y: 362F 0.433; Z: 112D 0.137
X: F22C 1.937; Y: 362F 0.433; Z: 1130 0.138
X: F22F 1.937; Y: 3630 0.434; Z: 1131 0.138
X: F22B 1.937; Y: 362E 0.433; Z: 112D 0.137
X: F233 1.938; Y: 362E 0.433; Z: 1130 0.138
X: F22A 1.937; Y: 362D 0.433; Z: 112E 0.137
X: F238 1.938; Y: 362F 0.433; Z: 112F 0.137
X: F227 1.937; Y: 362F 0.433; Z: 112E 0.137
X: F233 1.938; Y: 362C 0.433; Z: 112F 0.137
X: F22C 1.937; Y: 362B 0.433; Z: 112E 0.137
X: F233 1.938; Y: 362F 0.433; Z: 112E 0.137
X: F22F 1.937; Y: 362D 0.433; Z: 1131 0.138
X: F115 1.929; Y: 362D 0.433; Z: 112F 0.137
X: F238 1.938; Y: 3630 0.434; Z: 1131 0.138
X: F22F 1.937; Y: 3630 0.434; Z: 112F 0.137
X: F22A 1.937; Y: 362D 0.433; Z: 112F 0.137
X: F223 1.937; Y: 362F 0.433; Z: 112F 0.137
X: F22B 1.937; Y: 362C 0.433; Z: 1130 0.138
X: F22D 1.937; Y: 362F 0.433; Z: 112E 0.137
X: F233 1.938; Y: 3631 0.434; Z: 112E 0.137
X: F22D 1.937; Y: 362F 0.433; Z: 112F 0.137
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i tried running with your codes, however i get some random characters from the output on my hyperterm.
it is wierd.
thus i tried to force it to become a string become i use UART PrintString Function.(refer to attachment)
these are the wierd characters from my hyperterm screen:
E‡„...bãD‡¤D‡¥„bãD‡¥E‡†...bãD‡¥E‡Å„bãD‡...D‡¤...bãD‡¥D‡...„bãD‡...E‡„„bãD‡¥D‡Å„bãD‡ÅD‡Ä„bãD‡
...E‡...†bãD‡¤F‡¦„bãD‡...D‡¥†bãD‡...D‡¤„bãD‡...E‡¥„bãD‡„E‡¦...bãD‡¥E‡¦†bãD‡...D‡„...bãD‡ÅE‡......bãD
‡¤D‡¦...bãD‡¥E‡...„bãD‡¥F‡¤...bãD‡...E‡...„bãD‡¥E‡¦„bãD‡ÅE‡¦„bãD‡...E‡¤„bãD‡...F‡......bãD‡ÅF‡¦„bã
the changes i did:
tx_out is p04
vin1 is p01
vin2 is p02
vin3 is p03
char OutputString1[32];
char SerialOutString1[64];
i did some changes to the method:
void PrintResults(void)
{
// Clear the output string
strcpy(SerialOutString,"");
strcpy(OutputString1,"");
// Convert Z axis into Hex and display on LCD
sprintf(OutputString, "%x", ADCResult[0]);
// Add Z Axis value to the serial out string
strcat(SerialOutString, "Z:");
strcat(SerialOutString, OutputString);
strcat(OutputString1, "Z:");
strcat(OutputString1, OutputString);
LCD_Position(0,0);
LCD_PrintString(" ");
LCD_Position(0,0);
LCD_PrintString(OutputString1);
strcpy(OutputString1,"");
// Convert Z axis voltage into ascii and add to serial out string
//sprintf(OutputString, "%5.3f", Vin[0]);
//strcat(SerialOutString, " ");
//strcat(SerialOutString, OutputString);
// Convert Y axis into Hex and display on LCD
sprintf(OutputString, "%x", ADCResult[1]);
// Add Y Axis value to the serial out string
strcat(SerialOutString, "Y:");
strcat(SerialOutString, OutputString);
strcat(OutputString1, "Y:");
strcat(OutputString1, OutputString);
LCD_Position(0,8);
LCD_PrintString(" ");
LCD_Position(0,8);
LCD_PrintString(OutputString1);
strcpy(OutputString1,"");
// Convert Y axis voltage into ascii and add to serial out string
//sprintf(OutputString, "%5.3f", Vin[1]);
//strcat(SerialOutString, " ");
//strcat(SerialOutString, OutputString);
// Convert X axis into Hex and display on LCD
sprintf(OutputString, "%x", ADCResult[2]);
// Add X Axis value to the serial out string
strcat(SerialOutString, "X:");
strcat(SerialOutString, OutputString);
strcat(OutputString1, "X:");
strcat(OutputString1, OutputString);
LCD_Position(1,0);
LCD_PrintString(" ");
LCD_Position(1,0);
LCD_PrintString(OutputString1);
sprintf(SerialOutString1, "%s", SerialOutString);
// Convert Z axis voltage into ascii and add to serial out string
//sprintf(OutputString, "%5.3f", Vin[2]);
//strcat(SerialOutString, " ");
//strcat(SerialOutString, OutputString);
// Print the String to Serial port and terminate with CR and LF
UART_PutString(SerialOutString1);
UART_PutCRLF(0x20);
}
any advice, why i am getting the weird symbol?
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Have you configured the Hyperterminal for 19200 baud rate?
2. Check my project as it is without making any modifications, and see if it works. If my project works fine without any modifications and gives problem with your modifications, then we can troubleshoot the project. On the other hand, if my project does not work as it is, then there can be some problem with the hardware setup or hyperterminal setup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it works, i apologize that i over look the hyperterm settings, as i had been to used to setting it at "9600".
thanks for all these help.
cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content