-
Notifications
You must be signed in to change notification settings - Fork 227
Add 433 MHz transmitter example #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
can you add example how to receive the data? |
This example works with a simple transmit only board. I haven't used a receiver yet, but I can see if I can also make it work. Would you split this in two examples or put both in one? |
|
if the code is too big, I would split it into 2 if not one is ok i think. |
|
Is it possible to do both send and receive from one part? If so, that would be best. And I am glad you kept things simple, but I do think the minimum viable product would be both send and receive. |
|
So definitely not a no, @sodoku but, maybe a "when you get TX/RX going. Other than that the PR is good. |
|
@cnlohr I managed to solder my receiver antenna and play around a bit with it. Reading how rc-switch does the receive and looking through the ch32fun examples, it looks like I will need to use interrupts for the input data change detection and for being able to measure time difference ( |
|
@sodoku on ch32fun, you use uint32_t start_time = SysTick->CNT;
while( 1 )
{
// Do stuff
if( TimeElapsed32( SysTick->CNT, start_time ) >= Ticks_from_Ms(150) )
{
// 150ms elapsed.
start_time += Ticks_from_Ms(150);
}
} |
|
I spent hours on this and learned a lot, but somehow the timing values didn't make sense. I am not sure what I am doing wrong. I boiled my problem down to a very simple example: int miliseconds = 15000;
uint32_t start_time = SysTick->CNT;
while ( 1 )
{
// Do stuff
uint32_t diff = TimeElapsed32( SysTick->CNT, start_time );
if ( diff >= Ticks_from_Us( miliseconds ) )
{
start_time += Ticks_from_Us( miliseconds );
printf( "%lu \n", diff / DELAY_US_TIME );
}
}This works an outputs: However if I change What am I doing wrong? |
|
You need to do the math on the uint32_t but you need to compare based on int. I.e. if( (int32_t)TimeElapsed( SysTick->CNT, endTime ) > 0 )
{
endTime = SysTick->CNT + Ticks_from_Us( miliseconds );
}or if( (int32_t)TimeElapsed( SysTick->CNT, endTime ) > 0 )
{
endTime += Ticks_from_Us( miliseconds );
}if you don't want your timebase to slip |
|
I have given up with the 433 recieve (at least for now). I got none of the suggestions to work properly. The timings were never right. As a last resort, I wanted to make sure the receiver is not faulty. I tested it on an ESP32 with Arduino & rc-switch and it works fine on. I then tried to run the same code on wch arduino & rc-switch. Just had to make on simple change from attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);to attachInterrupt(this->nReceiverInterrupt, GPIO_Mode_IN_FLOATING, handleInterrupt, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling); It compiles and runs, the interrupt fires, but rc-switch can't decode the timings. I might look at receive again after I had some more time to learn about the CH32V003, ch32fun and lower level microcontroller programming. |
I was playing around with 433Mhz and thought this might help someone. Feel free to reject if this is too basic.