Hi ,people. I'm try to connect PSoC 4 pioneer Kit with MatLab to graphing the data. when i receive one data the program work fin, but when add more sensor i have problem. the information was plotted is wrong, don't have coherence.
then, some one could give me suggestion??
very thanks in advance
happy new year..!
It is difficult to say anything about the interface unless one has seen the code on both side (PSoC 4 BLE, MATLAB).
But from your description, could it be an issue with the string of data sent from PSoC 4 BLE to MATLAB?
In the side of MatLab (which controlled the communication)
fprintf(serial_PSoC,'%c','a');%with this i select which sensor I want to graphic
pause(0.1);
% variable=fread(serial_PSoC,4,'%f');
% recepcion_ADC= str2double(variable);
recepcion_ADC=fscanf(serial_PSoC,'%f');
ADC(contador)=recepcion_ADC(1);
figure(1)
subplot(2,2,1)
plot(ADC,'b');
.......
In the side of Creator (which is controlled or expected to receive what data is to transmit )
//CyDelay(55);
UART_ClearTxBuffer();//clean buffer
if(sensor_mux==1)//this work fine
{LED_Verde_Write(0);
UART_ClearTxBuffer();//clean buffer
UART_PutString(volt);//char volt[5]
//CyDelay(5);// delay for the bufer (don't work)
UART_ClearTxBuffer();//clean buffer
LED_Verde_Write(1);
}
else if(sensor_mux==0)
{
LED_Verde_Write(0);
UART_ClearTxBuffer();//clean buffer
UART_PutString(temp);//char temp[5]
//CyDelay(5);// delay for the bufer (don't work)
UART_ClearTxBuffer();//clean buffer
LED_Verde_Write(1);
}
It is not a good practice to clear the UART buffers except when there was an error detected.
PutString() is blocking, so when there is no room in the buffer, the API will wait, interrupts must be enabled.
It would be easier for us to check your program when you provide us with a complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
Your handling of UART still has a lot of clear buffers() which only will lead to errors. The buffer is handled by the component when the interrupt is set to "internal" as you did for Tx.
Your declarations
char volt[1],volt1[1],c[1];
only reserve one (1) byte for each variable, but you use them with sprintf() which will overwrite the variables following to your declaration. Increase the size to (more than) the required amount of the expected string.
Bob