📜 ⬆️ ⬇️

We master the CC430 - microcontrollers with a radio module: do-it-yourself photo finish

The Texas Instruments CC430 microcontroller series is an MSP430 with an integrated radio module. In domestic online stores, you can buy TE-CC430F51-433 modules that contain such a microcontroller with quartz and a bunch of other useful parts on a tiny board, at a quite affordable price. In this article I will talk about building a photo finish on the basis of such modules - a device that is very useful for sports fans. On it naturally the potential scope of application is not limited. The presence of a 12-bit ADC, hardware multiplier and other peripherals opens up a wide range of applications that require data transmission over a distance of several hundred meters.

A photo finish needs a radio channel because it consists of two spatially separated parts - a start and a finish. The start knows the time when the participant started, and the finish determines the moment when he finished. To do this, a photo barrier is organized at the finish - a beam of infrared light that is interrupted by the finishing participant. Consider these two devices in order.

Start module




We will need a battery, a PW power switch, a START start button, a MODE / PING channel mode select / test button, a squeaker for a finishing signal, and a seven-segment 4-digit indicator to indicate the time. All this connects directly to the module. As an antenna, you can use a piece of wire with a length of 20-25 cm, and you can take ready. The antenna also connects directly to the module - all necessary matching circuits on it are already unsoldered.
')

Finish module



For the light barrier, we will use a ready-made IR receiver similar to those used in televisions. To protect against daylight, it is useful to install it in a fairly long blackened tube. As a source, take one or more IR LEDs. One can be easily connected directly to the module leads, and for several you will have to make an additional transistor switch (not shown in the diagram). In order not to spread the light source with the receiver, they are mounted side by side in one direction, and on the other side of the track where participants finish, they put a reflector (reflector). In addition to the light barrier at the finish line, there are the same elements as at the start — the battery, the PW power switch, the PING channel test button, the squeaker and the seven-segment indicator. To adjust the light barrier, use the CALIB calibration mode switch and the CALIB LED, which indicates that it is turned on.

Radio channel


The radio module (or transceiver) is represented by a set of registers, where it is necessary to register a fair amount of settings. So that the user does not suffer from reading the documentation for their invention, the manufacturer provides free of charge a special program SmartRF Studio. Another complication is that the transceiver registers are not in the address space of the microcontroller. They are accessed through another set of registers called the RF1A radio interface. The root of this strange architecture is that the transceiver exists as a completely separate from the processor chip CC1101, so its registers are not connected to the processor in any way.

Since we do not need to transfer large amounts of data, we are satisfied with the minimum bit rate, which will give us better sensitivity and noise immunity. Reading the documentation allowed us to set the transmission speed to about 200 baud, which is even less than the minimum speed that SmartRF Studio allows to set. As a result, the modules confidently communicate with each other at a distance of 300-400 meters using a piece of wire as an antenna. The transceiver allows you to use any of the 256 channels. The first channel has a frequency of 400 MHz, adjacent channels are separated from each other by 200 kHz.

How it works


Finish turns on first. And the start and finish immediately after switching on show the battery voltage. First set up the light barrier. To do this, close the switch CALIB. In this position, the absence of a signal in the IR receiver is signaled by a squeak. When the settings are completed, CALIB is turned off. After that, the microcontroller still checks for the presence of a signal in the receiver, but does so less frequently, saving the battery. Upon detecting the disappearance of a signal, it sends a message to the start, which is shown on the display by noIr .

If after turning on the power at the start, press the MODE / PING button, it starts to loop through the channels, showing their numbers on the display until the user selects a channel to communicate with the finish. At the same time, a message is sent to the finish line with the channel number and session ID — a random number that will be sent in all subsequent messages. To transmit this first message, a dedicated service channel with the number 0x40 is used. After receiving a response from the finish line, the start remembers the time taken to send a message.

If you press the start button, a message is sent to the finish line, containing the time from which to start the countdown - this is the time the message was transmitted, which the start was remembered in the previous step. After receiving it, the finish line starts the time count and turns on the IR emitter. A sequence of 16 pulses with a carrier frequency of 38kHz is fed to the IR LED. The intersection of the light barrier is fixed if the output signal of the receiver is absent at the moment when the last pulse of the sequence ends. At this moment, a message is sent to the start containing the current time, which is later shown in the start and finish on their displays.

If the start and finish are not busy measuring the time of the participant, pressing the PING button on any of them results in sending a test message. Upon receipt of a response, the display shows the received signal level (RSSI) - a number in a logarithmic scale. It was experimentally found that values ​​below 0x30 lead to a rapid loss of communication.

If, after establishing a connection, the starting module has been turned off, it can be switched on with the restoration of communication in the same channel. To do this, hold down the MODE / PING button while turning it on until the message reSu appears . In this case, the start sends the finish message in the channel that he remembers, as a result the finish restarts, and the start re-establishes the connection using the old channel number. If you turn the MODE / PING button on for longer, until the teSt message appears , the start and finish begin the self-test procedure, during which they establish a connection in all channels in turn.

Source


git clone git: //git.code.sf.net/p/wtb430/code wtb430

IAR was used for compilation. As a bootloader, I used the MSP-EXP430G2 LaunchPad board, connecting it with wires to the terminals of the TEST, RST module.

Source: https://habr.com/ru/post/245035/


All Articles