CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

manchester decode
Goto page Previous  1, 2, 3 ... 11, 12, 13 ... 18, 19, 20  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 6:51 am     Reply with quote

sigh, I've been so focused on the 'data' aspect, I forgot about the 'sync' requirement.
Of course it'll never,ever work..

It needs a total rewrite, back to the beginning, literally.....
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 7:14 am     Reply with quote

God damn it, I'm running out of hope on this issue. If you could help me, I'd be grateful.
PrinceNai



Joined: 31 Oct 2016
Posts: 527
Location: Montenegro

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 8:17 am     Reply with quote

I believe that is the reason for that lonely zero at the beginning, which is not part of the actual dala sent out.
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 8:31 am     Reply with quote

OK, start fresh.

Create a program that SEES the 'preamble or sync or whatever you want to call that series of 8 pulses that are 2.5 ms wide.
My idea is to measure a pulse, if 2.5ms wide, increment a counter,loop looking for more.....
When you have 8, delay for say 1ms(?), then flash an LED,
Your logic analyzer should show the 'remote ' data as well as the LED status.

You need to do this before trying to read/decode the buttons.
there are 1,000s of hit for 'measuring pulse width with PIC', check code library here,could be something close to what you need.
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 9:08 am     Reply with quote

Thank you masters, I will do what you said and publish it here
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 5:24 pm     Reply with quote

As you said, I did the preamble reading part and tested it. The preamble decode part works. 7 bytes of preamble data are taken, then the header part is taken, then the Manchester decode part is started, but in this way the Manchester decode part does not work.

Last edited by bulut_01 on Mon Feb 24, 2025 1:40 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 02, 2025 8:10 pm     Reply with quote

OK had a quick look...
and I think the program needs to do the following..

main()
loop starts here
enable CCP3 interrupt
now..... CCP3 ISR waits for 7 pulses ,sets flag 'sync found'
disable CCP3 interrupt //could be 2nd last line in CCP3 ISR
might need a delay(1ms) here....//a pause between sync ...and ... data
enable timer0 interrupt// could be last line in CCP3 ISR
now... timer 0 captures ' 7 bytes of data'
disable timer0 interrupt // could be last line in Timer0 ISR
parse buffer B[] to get key pressed
send information to PC terminal program

loop ends here


The data in B[] should look like the actual bytes in the logic analyzer

You have to disable the CCP3 interrupt when 'sync' is found , otherwise real 'data' will cause CCP3 interrupts.Same for the Timer0 ISR. 'clearing' an interrupt only 'resets' the flag that an interrupt occoured. 'disable' prevents all incoming pulses on the input pin from doing 'anything'.

curious why the 1600 baud rate for the RS232 to PC ?

You're making great progress !! It's best to learn by doing, that way you'll understand WHAT is happening better.
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Mon Feb 03, 2025 5:25 am     Reply with quote

temtronic wrote:
OK had a quick look...
and I think the program needs to do the following..

main()
loop starts here
enable CCP3 interrupt
now..... CCP3 ISR waits for 7 pulses ,sets flag 'sync found'
disable CCP3 interrupt //could be 2nd last line in CCP3 ISR
might need a delay(1ms) here....//a pause between sync ...and ... data
enable timer0 interrupt// could be last line in CCP3 ISR
now... timer 0 captures ' 7 bytes of data'
disable timer0 interrupt // could be last line in Timer0 ISR
parse buffer B[] to get key pressed
send information to PC terminal program

loop ends here


The data in B[] should look like the actual bytes in the logic analyzer

You have to disable the CCP3 interrupt when 'sync' is found , otherwise real 'data' will cause CCP3 interrupts.Same for the Timer0 ISR. 'clearing' an interrupt only 'resets' the flag that an interrupt occoured. 'disable' prevents all incoming pulses on the input pin from doing 'anything'.

curious why the 1600 baud rate for the RS232 to PC ?

You're making great progress !! It's best to learn by doing, that way you'll understand WHAT is happening better.


mr.temtronic Thank you for your wishes, I am publishing 3 versions. The Manchester decode section is stubborn and does not work. When I close the ccp3_int cut, I cannot open the ccp3_int in the Manchester decode section because the code does not work in the Manchester decode section. I did what they said but could not get the result.
baund 1600 It doesn't make sense, it's a setting from the past.


Last edited by bulut_01 on Mon Feb 24, 2025 1:40 pm; edited 1 time in total
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Mon Feb 03, 2025 2:28 pm     Reply with quote

I am sure about the 4 settings here why the code is not working

Code:

#define HIGH_TO -10           
#define LOW_TO   10         

#define SHORT_HEAD 20         
#define LONG_HEAD  45


it is not clear what the values ​​of these should be, what the units are, when I debug it is stuck in the synchronization header and the measurement is reset
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 03, 2025 4:42 pm     Reply with quote

here's the logic I'm thinking you need..

while(true){
///////////////////////////////////////////////////////////////////////////////
enable_interrupts( INT_CCP3); // this aloows PIC to 'see' the sync'
if(works==1) { //got 'sync' !!
disable_interrupts(INT_CCP3); //stop 'data' from triggering the 'sync' ISR
enable_interrupt( Timer0); // now get 'data' bits
}
if(ready==1) { //got 'data' !!
disable_interrupts(Timer0);
ready_(); //display 'data' buffer B[] contents
}
if(XTMR < 512){
XTMR=0;
}
//
init_receiver();
delay_ms(50); //just a small main loop delay.
}


in main()
1st you setup registers and stuff but do NOT enable the interrupts
in a loop.....
you enable the CCP3 ISR and it gets 'sync'
then disable CCP3 interrupt ,
then enable the timer0 ISR ,and collect the 'data'
then disable Timer0 interrupt.
then send 'data' to PC screen
than small delay
then go back to top of loop

It does compile but I can't test. it was also very hard for me to see the screen, old age,light fonts, sigh.

Think of the program 'flow' like a 'high security' building double door entrance

you unlock the 1st door ( enable the 'sync' interrupt' )
open and enter ( 'sync' bytes found ! )
lock the 1st door (prevent following bytes in )
unlock 2nd door( enable timer0 interrupt
open and enter house ('data' bytes found ! )
lock 2nd door ( disable timer0 )
show data ( send 'data' to PC )

I may not have it exact , hope you can understand the 'flow' of operations...
You're really close though !!!
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 6:33 am     Reply with quote

temtronic wrote:
here's the logic I'm thinking you need..

while(true){
///////////////////////////////////////////////////////////////////////////////
enable_interrupts( INT_CCP3); // this aloows PIC to 'see' the sync'
if(works==1) { //got 'sync' !!
disable_interrupts(INT_CCP3); //stop 'data' from triggering the 'sync' ISR
enable_interrupt( Timer0); // now get 'data' bits
}
if(ready==1) { //got 'data' !!
disable_interrupts(Timer0);
ready_(); //display 'data' buffer B[] contents
}
if(XTMR < 512){
XTMR=0;
}
//
init_receiver();
delay_ms(50); //just a small main loop delay.
}


in main()
1st you setup registers and stuff but do NOT enable the interrupts
in a loop.....
you enable the CCP3 ISR and it gets 'sync'
then disable CCP3 interrupt ,
then enable the timer0 ISR ,and collect the 'data'
then disable Timer0 interrupt.
then send 'data' to PC screen
than small delay
then go back to top of loop

It does compile but I can't test. it was also very hard for me to see the screen, old age,light fonts, sigh.

Think of the program 'flow' like a 'high security' building double door entrance

you unlock the 1st door ( enable the 'sync' interrupt' )
open and enter ( 'sync' bytes found ! )
lock the 1st door (prevent following bytes in )
unlock 2nd door( enable timer0 interrupt
open and enter house ('data' bytes found ! )
lock 2nd door ( disable timer0 )
show data ( send 'data' to PC )

I may not have it exact , hope you can understand the 'flow' of operations...
You're really close though !!!


mr. temtronic I did exactly what you said, but the Manchester decode part is not working. I added the simulation images. The Manchester decode cannot pass the reset part in the code part. The code does not recognize headers or there is another reason for the problem here.

Check out the pictures below and I hope you understand what I mean.


Last edited by bulut_01 on Mon Feb 24, 2025 1:41 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 7:22 am     Reply with quote

Sorry, I can't help you with any PROTEUS projects, as it's well known that it does not actually work properly. One glaring error in the picture, have a look at D1, the red LED.
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 7:56 am     Reply with quote

temtronic wrote:
Sorry, I can't help you with any PROTEUS projects, as it's well known that it does not actually work properly. One glaring error in the picture, have a look at D1, the red LED.


The issue is not Proteus, I am trying to show you the truth, I am trying to explain that the Manchester decode code cannot pass the sync section, I think the reason is the header section, maybe it is in the setting.
temtronic



Joined: 01 Jul 2010
Posts: 9437
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 8:27 am     Reply with quote

query.
Are you using real hardware or is this a Proteus Simulation ?
bulut_01



Joined: 24 Feb 2024
Posts: 218

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 9:59 am     Reply with quote

I am using real hardware. I see real circuit values ​​by putting putc in some places. Whatever I see in Proteus, I see the same value in the real circuit. This timer0 overflow decode needs to have a 72 ms cycle, is that correct?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3 ... 11, 12, 13 ... 18, 19, 20  Next
Page 12 of 20

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group