Categories

RoseOnRails – Tests PCB are ready

Hi everyone !

On Wenesday, I didn’t have a lot of time to work. But I worked after my FH courses and after the session of improvisation. I’ve worked on the configuration of our STM32F103 because we realized during the afternoon that it wasn’t possible to use DMA on USART1 and SPI2 at the same time. See DMA tables for our STM32F103DMA_table

Luckily, this problem happens on the board Rose’s students were using last year, so we manage to correct this problem before our LED PCB arrive. Unfortunately, we’ve connected our STM32F103 with our nRF51822 through USART1. So we have the same problem (it doesn’t matter now because we aren’t using DMA for the UART communication). But, I would recommend to everyone who wants to do a communication between a STM32 and another device through UART to have a look at the DMA table first.

Because of this problem, the code I’ve made using ChibiOS wasn’t working because the STM32 couldn’t allocate two times the channel 5 of his DMA1. So, we configure our UART properly. This raise another issue how to handle interruption properly with ChibiOS. We did it on Thursay using a mailboxe and a CH_IRQ_HANDLER. Unfortunately, we made a mistake while configuring the BR register of our UART.

Because in the UART config of ChibiOS, the br field is directly the speed

/**

* @brief Bit rate.
*/
uint32_t speed;

But it was very easily corrected with a “grep -r speed” in ChibiOS files.

/* Baud rate setting.*/
#if defined(STM32F0XX)
if (uartp->usart == USART1)
u->BRR = STM32_USART1CLK / uartp->config->speed;
else
u->BRR = STM32_PCLK / uartp->config->speed;
#else /* !defined(STM32F0XX) */
if (uartp->usart == USART1)
u->BRR = STM32_PCLK2 / uartp->config->speed;
else
u->BRR = STM32_PCLK1 / uartp->config->speed;
#endif /* !defined(STM32F0XX) */

Thus because we’re using USART1 on STM32, we just changed our configuration the following way USART1->BRR = STM32_PCLK2 / 38400;

I would recommend you not to read the complicate explanation in the reference manual about how to configure DIV_Mantissa and DIV_Fraction to get the speed you want. Because if you use the ChibiOS macro the formula is easy : STM32_PCLK(clock number for your uart 1 or 2) / speed.

So as explained in Valeh’s post. Our test is now working properly.

On Friday we had our presentation. Then, we looked with Gleison to find an optic detector to enable our train to detect our LEDs. I think they were a confusion in our mind because I remember we said we could abandon using this optic detector if we detect our train position precisely enough. Thus, we didn’t provide any analog entry on the nrf51822 for the optic detector and finding a numerical one wasn’t easy. After some calculations and discussion, we decided to focuse ourself on detecting the train position with hall sensors. As we had decided a few times ago we’re going to use a bar code system (detecting north and south pole of our magnet). It depends on the budget but to get enough precision we should use enough benchmarks. We already have 78 magnets.

If we use barcodes with 6 magnets
Number of magnets necessary : 64*6 =384
Cost = 306*0.18 = 55.08 €
Accuracy : 28/0.64 = 43.75cm
If we use barcodes with 5 magnets
Numbers of magnets necessary : 32*5 = 160
Cost : 82*0.20 = 16.400 €
Accuracy : 28/32.0 = 87,5 cm

After, making this calculation Gleison explained us how the test of the turnout PCB works. Then, we finished the tests for the locomotive PCB including the adc test and the hall sensors test which enables us to receive data from the hall sensors through BLE.
Today, I’m going to look at how to implement our BEMF, improve the way we communicate through BLE with our central station because BlueLib seems to have latency compared to gatttool commands, and look at the implementation of the intelligence of our games.

 

Commentaires fermés.