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

cross mob
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Provided below is the SerialRx v0.0 component implementing simple command line interface between UART Terminal and PSoC microcontroller.

Using this component, human-readable UART Terminal messages can be easily received and processed by the microcontroller. Component is, in essence, a software library, which splits the incoming stream of bytes into individual control messages using standard termination characters.

Component features:

* Compatible with PSoC4 SCB UART and PSoC5 UART
* Optional external or internal interrupt mode
* Standard \n and \r termination characters
* Optional Comma, Space and Tab separators

Component can be useful for process control or parameters update, such as: PID tuning, setting control voltages, PWM frequency, etc. Component is compatible with Creator 4.0 and Creator 4.4, and was tested using CY8KIT-059 PSoC5LP Prototyping Kit and CY8KIT-044 PSoC4M Pioneer Kit. Demo projects are provided.

Attached archive contains component library, component datasheet and several demo projects for PSoC4 and PSoC5. Please read installation instructions in the readme.pdf.

Credits:
     Bob Marlowe (Cypress, ret.)

 

Figure 1. PSoC4 SCB UART basic project schematic using SerialRx. The Component receives messages from the Terminal and turns RGB LED on/off. Both SCB UART and SerialRx are configured for internal interrupt mode.

SerialRx_P4_SCB_basic_01a_A.png

 

Figure 2. Terminal window showing command messages and PSoC4 responses. Recognized commands ('R_ON') are executed with confirmation echo sent back ('>R_ON'). Unrecognized commands ('foo') are ignored and an error status is reported ('!foo').

SerialRx_P4_SCB_basic_01a_Putty_4.png

3 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

This is one of the demo projects showing  RGB LED brightness control using PWM and external UART Terminal.  

Operator sends consecutive commands: ‘R255’, ‘G32’ and ‘B64’ to adjust the brightness of the RGB LED. Here ‘R’, ‘G’ and ‘B’ – are predefined one-byte control commands, and the rest of the command carries the associated control value. For example: ‘R255’ (set the PWM_R compare value to 255).

Upon receiving the message, the commands are: (i) identified by the control byte; (ii) the payload string is validated to be a numeric value; (iii) the extracted value is checked to be within the pre-defined range; (iv) the value is applied to the corresponding PWM block. The executed commands are echoed back with the acknowledgement: ‘>R255’.  

Commands, which are not recognized (e.g. ‘foo’) are ignored by the controller with error notice echoed back: ‘!foo’. Likewise, an error is reported anytime the payload string can’t be converted to a numeric value (e.g. ‘G_255’), or when the value received falls out of control range (‘G-1000’).

Project name: SerialRx_P4_RGB_01a.cyprj

 

Figure 1. Project schematic. PWM_R, G and B control the brightness of the onboard RGB LED.  The SerialEx receives messages from the Terminal and adjusts brightness of the LED according to the value received.

SerialRx_P4_SCB_01a_A3.png

 

Figure 2. Terminal window showing command messages and PSoC4 responses (the line feed '\n' character is not displayed). Recognized commands ('R255' etc.) are executed with a confirmation echo ('>R255'). Unrecognized commands, or those, which failed validation ('R-1000') are ignored, and error status is reported back ('!R-1000').

SerialRx_P4_SCB_01a_Putty_PWM_4.png

lock attach
Attachments are accessible only for community members.
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Hi There!

Thank you very much for share with me your interesting project with SerialRx component.

What I shared with you just was the tip of the icberg,  I moved forward and I achieved (also as you) an echoed to the characters send from  4 Excel cells to PSoC 5LP  and back to 4 diffents Excel cells.

The code so far just send and receive numeric character ( integers and floats), not yet other character due to the particular way I processed the string I posted to you from the debugger snapshot.

Also, I am working on optimize my code, accept alphabetical character, do some cosmetic and a clear  code explanation to be undestood.

Once that is done I will post the code..

Greetings

I am attching an excel sheet  snapshoot  that show what was done.

 

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Attached is v0.1 of the SerialRx component, which has minor updates and fixes. Please read the datasheet for details.

0 Likes