Page 1 of 1

Ballistic chrono, simulation, arduino and blue pill

Posted: Sat Aug 08, 2020 8:43 pm
by dannyf
I have been working on coding the cheapest and simplest chrono https://dannyelectronics.wordpress.com/ ... f-concept/ to measure speed of a bullet -> itself not that interesting.

Before I got the hardware up and running, I used a lot of simulation to test out different approaches. One of the questions I got was "just how good are the simulators?". Towards the end of the page here https://dannyelectronics.wordpress.com/ ... ototyping/, I ran the same code (other than for the display types, common anode vs. common cathode), and the simulator and the actual hardware showed the exact same results: both showed 1,613m/s - for the testing purposes the mcu generated its own input pulses.

I was actually surprised at how "close" it has been - maybe I'm lucky, :).

Now, the arduino / stm32 content:
1. I ported a version of the code to Arduino and it actually ran / simulated well. the AVRs are much easier to work with.
2. I also ported a version of the code to a blue pill (herehttps://dannyelectronics.wordpress.com/ ... f-concept/, towards the end of the page), and it ran well too -> the display used then doesn't show decimal points but other than that, it was fine. It is an overkill with the bluepill but the form factor fits in nicely: the LED (a 0.56" 4-digit, 7-segment type) sits on the back of the board.
3. on the STM32F103, the reuse of PB4 for GPIO may be of use to others, so I would reproduce it here:

Code: Select all

	//remap RB4 to GPIO
	RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;			//1->enable clock, 0->disable clock
	AFIO->MAPR = 	(AFIO->MAPR &~AFIO_MAPR_SWJ_CFG) |	//clear SWJ bits
					AFIO_MAPR_SWJ_CFG_NOJNTRST |		//0x01->use NJRST pin for GPIO
					0x00;