Page 1 of 1

Beginner needs Help

Posted: Thu Dec 01, 2016 11:21 am
by Alfred00
Hello,

i want to measure distance with an ultrasonic senosor. I have the xmos Starterkit and an ultrasonic sensor. I did some programming on the Starterkit but when i tried to use the Sensor i failed. Its my first time working with something like that so i dont rly know what to do.
First I need to figure out which Sensor-pins I need to connect to which Ports on the Starterkit. If anyone has any tips or can help me i would appreciate it.
Secondly when the Senosr is connected i need to write code and make the Sensor/distace measuring work.(first things first)

Any help is welcome.

BR,
Alfred

Re: Beginner needs Help

Posted: Thu Dec 01, 2016 1:23 pm
by mon2
Hi Alfred00. Here are some suggestions to point you in the right direction (pun intended :)..

1) always power your external ultrasonic module from 3v3 (not 5v0). The reason being that the XMOS device on the startKit is not 5v0 tolerant so the respective GPIO pins on the startKit can be damaged if mated with a voltage level of > 3v3.

2) Recommend that you review the startKit datasheet to track down the 1 bit ports for the interface.

https://www.xmos.com/published/startkit-hardware-manual

J6 offers

3v3 ; connect to the ultrasonic module pad marked +5

&

ground ; connect to the ultrasonic module pad marked GND

to power this module.

The module datasheet claims to require 2 mA @ 3v3 which is just fine for this project being powered all by the USB interface.

Next are the interface pins. Recommend that you mate with single bit port pins to allow for the most flexibility as you work more with this module. Consider to use the UART interface method and later can move to the PWM mode. Both are very simple tasks for the XMOS CPU to support. Keep in mind again that if you power this module from 3v3, the port pins on the module will remain compliant with 3v3 voltage swings for use with the XMOS startKit.

Review page 7, jumper J7 for a list of available port pins.

You have many choices but let us drill down to some concrete mappings:

P1F0 ; X0D13 connect to your module TX pad
* means that you are on tile X0 = Tile 0
* means that you are connecting to pin X0D13 on the CPU
* means that you are working port 1F with bit 0
* J7 pin 1

P1H0 ; X0D23 connect to your module RX pad
* means that you are on tile X0 = Tile 0
* means that you are connecting to pin X0D23 on the CPU
* means that you are working port 1H with bit 0
* J7 pin 2

P1G0 ; X0D22 connect to your module PW pad
* means that you are on tile X0 = Tile 0
* means that you are connecting to pin X0D22 on the CPU
* means that you are working port 1G with bit 0
* J7 pin 3

P1E0 ; X0D12 connect to your module BW pad
* means that you are on tile X0 = Tile 0
* means that you are connecting to pin X0D12 on the CPU
* means that you are working port 1E with bit 0
* J7 pin 4

For now, leave AN pin on the module open since the AN pin will output an analog voltage which will be relative to the distance being measured. That is, you will need an A/D convertor (analog to digital convertor) to make sense of the distance being measured by the sensor.

Instead, use the TX pin which will output in a serial (UART) mode, the same data in a simple format of 9600,N,8,1 framing. From the datasheet:
The baud rate is 9600, 8 bits, no parity, with one stop bit.
Configure the port pins on the module to suit. For UART mode, it appears that you can just leave all of the XMOS port pins in input mode which means the module will power up in default to output the distance on the TX pin @ 3v3 voltage swing.

Use the XMOS UART library and configure the parameters to suit this module:

https://www.xmos.com/support/libraries/lib_uart

Change the port pins and target board to the startKit mapping -> compile and start testing !

Feel free to post what you are using now for the port pin mappings

Re: Beginner needs Help

Posted: Thu Dec 01, 2016 1:29 pm
by Alfred00
Thanks for the answer ill work through it when im home. :)