View previous topic :: View next topic |
Author |
Message |
DG7GJ
Joined: 21 Jan 2010 Posts: 6
|
Posted: Mon Jan 31, 2022 7:15 pm Post subject: What function for exact asynchron ASK/OOK-Transmit? |
|
|
Hello,
what is usefull to transmit an ASK-Stream of manchester-coded bitstreams?
I will build an ASK-Transmitter to send sensordata with raund 1024bps manchester-coded (eff. 512bps).
The UART I can't use, because ther may no start- or Stopbits in the stream.
I²C and SPI can't slow down to 1024bps.
Für Binary Manchester "01" i want 488µs Off and 488µs On.
For "0011" i want 976µs Off and 976µs On
This testing code will works to 70%, but with timing errors:
Code: |
'Einfacher Testsender für ASK-Empfängertest
$regfile = "m328pdef.dat" 'ARUNDIO-NANO Prozessor
$crystal = 16000000 'ARUNDIO-NANO Originalquarz
$hwstack = 40
$swstack = 40
$framesize = 40
$baud = 4800
Config Portb = &B11111111 'Pull Up Deaktiviert (0) oder aktiviert (1)
Config Portc = &B11111110 'Pull Up Deaktiviert (0) oder aktiviert (1)
Config Portd = &B11111111 'Pull Up Deaktiviert (0) oder aktiviert (1)
Ddrb = &B11111111 'definieren der verwendeten Ports ( 1 = ausgang; 0= eingang)
Ddrc = &B11111111 'definieren der verwendeten Ports ( 1 = ausgang; 0= eingang)
Ddrd = &B11111111 'definieren der verwendeten Ports ( 1 = ausgang; 0= eingang)
Dim Paket1(22) as Word
Dim Paket2(30) as Word
Dim N as byte
Paket1(1) = &h6666 'Dotting
Paket1(2) = &h6666 'Dotting
Paket1(3) = &h6666 'Dotting
Paket1(4) = &h6666 'Dotting
Paket1(5) = &h9696 'Syncword
Paket1(6) = &h9996 'Paketnummer
Paket1(7) = &h9966 'ID1
Paket1(8) = &h6666 'ID2
Paket1(9) = &h6699 'ID3
Paket1(10) = &h6699 'Kanal
Paket1(11) = &h6996 'RC-Code
Paket1(12) = &h6696 'RC-Code
Paket1(13) = &h6999 'RC-Code
Paket1(14) = &h6999 'Zehntel xx,X°C
Paket1(15) = &h9999 'Einer xX,x°C
Paket1(16) = &h9699 'Zehner Xx,x°C
Paket1(17) = &h9999 'Sign
Paket1(18) = &h6699 'EXOR-CRC
Paket1(19) = &h6999 'EXOR-CRC
Paket1(20) = &h6996 'CRC8
Paket1(21) = &h9699 'CRC8
Paket1(22) = &h0000 'Ende
Paket2(1) = &h6666 'Dotting
Paket2(2) = &h6666 'Dotting
Paket2(3) = &h6666 'Dotting
Paket2(4) = &h6666 'Dotting
Paket2(5) = &h9696 'Syncword
Paket2(6) = &h9996 'Paketnummer
Paket2(7) = &h9966 'ID1
Paket2(8) = &h6666 'ID2
Paket2(9) = &h6699 'ID3
Paket2(10) = &h6699 'Kanal
Paket2(11) = &h6996 'RC-Code
Paket2(12) = &h6696 'RC-Code
Paket2(13) = &h6969 'RC-Code
Paket2(14) = &h6999 'Sekunde Einer
Paket2(15) = &h9999 'Sekunde Zehner
Paket2(16) = &h9699 'Minute Einer
Paket2(17) = &h9999 'Minute Zehner
Paket2(18) = &h6699 'Stunde Einer
Paket2(19) = &h6999 'Stunde Zehner
Paket2(20) = &h6996 'Kalendertag Einer
Paket2(21) = &h9699 'Kalendertag Zehner
Paket2(22) = &h9669 'Monat
Paket2(23) = &h9699 'Wochentag
Paket2(24) = &h6999 'Jahr Einer
Paket2(25) = &h9699 'Jahr Zehner
Paket2(26) = &h9666 'EXOR-CRC?
Paket2(27) = &h6996 'EXOR-CRC?
Paket2(28) = &h9669 'CRC8
Paket2(29) = &h9969 'CRC8
Paket2(30) = &h0000 'Ende
Do
Portc.0 = 0
Print "Starte scheife..."
wait 5
Gosub Send1
wait 5
Gosub Send1
wait 5
Gosub Send1
wait 5
Gosub Send1
wait 5
Gosub Send2
Loop
Send1:
Print "Sende Paket1"
Printbin Paket1(1)
For N = 1 to 21
Shiftout PortC.0, Portc.1, Paket1(N), 0, 16, 240
Next
Print "Paket1 gesendet!"
Portc.0 = 0
Return
Send2:
Print "Sende Paket2"
Printbin Paket2(1)
For N = 1 to 29
Shiftout Portc.0, portc.1, Paket2(N), 0, 16, 240
Next
Print "Paket2 gesendet!"
Portc.0 = 0
Return
|
With an Shiftout-delay of 240µs the correkt timing is the result: For one Mancester-Bit exact 488µs and 976µs for two identical Manchester-Bits.
But on various positions of the Arrays there are timings of 386µs and sometimes 830µs between the crosspoints.
On the receiver this wrong time is interpreted as an Error or <EOT>.
How can I build an Bitstream with only 488 and 976µs timing without this errors?
Will Shiftout not usefull for long Arrays and exact timing?
All Bascom-projects I found in web uses an Hadware- or Software-UART with start and Stop-Bits, sometimes with Parity too.
Nothing of them is usefull for my ready Manchester-coded stream that must be only toggel the data-Input of an ASK 433MHz transmitter with the correct timing of 488 or 976µs on/off.
Is the only usefull way realy to use an Timer for this Job?
Juergen
(BASCOM-AVR version : 2.0.8.5 ) |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Mon Jan 31, 2022 9:18 pm Post subject: |
|
|
Hi,
I'd use a timer to toggle the output, that's the only way to get accurate timings (you just need to make sure that other interrupts don't take too long/delay the timer).
I did something with a simple protocol (<500µs on and 500µs off for Binary 0 and >700µs on and 500µs off for Binary 1) . If I find the code I'll post it here.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Feb 01, 2022 9:20 am Post subject: Re: What function for exact asynchron ASK/OOK-Transmit? |
|
|
DG7GJ wrote: | The UART I can't use, because ther may no start- or Stopbits in the stream. |
You miss 'USART in SPI Mode', which the ATMega328 can do. No start- nor stop-bits and runs even slower than you desire.
The problem would be in case your application is not truly standalone: there's only one USART available in ATMega328.
Communicating with the controller would be still possible, but more complicated by switching mode of USART.
Btw. for storing constants it is 'cheaper' to use flash, instead of the lesser available SRam. |
|
Back to top |
|
|
DG7GJ
Joined: 21 Jan 2010 Posts: 6
|
Posted: Tue Feb 01, 2022 7:48 pm Post subject: |
|
|
Thank you!
Now I'm sure that the SHIFTOUT not usefull for asyncron sendig with exact Baudrate and timing.
Some days ago I was reading about the UART in SPI-Mode, but I was not shure about the timing.
I will look on UART in SPI-Mode again, and RC5SEND hears good to.
Thanks! |
|
Back to top |
|
|
|