
yg ini juga bisa dimodif jd ppm decoder koq: viewtopic.php?f=121&t=14139
Moderator: widodo
NF wrote:coyo wrote:wah
klo Rx nya ga support, buat yg hobby elektronika bisa bikin sendiri "PPM-decoder", misalnya:
versi PIC: http://homepages.paradise.net.nz/bhabbott/decoder.html
versi Atmel:
....artinya suhu coyo bisa buatkan ?
.......................................................................................................................................................
Code: Select all
' #################################################
' #### ###
' #### PPM-Encoder ###
' #### Version 1.0 ###
' #### PPM-Decoder and SMART-PPM-Decoder ###
' #### ###
' #################################################
' Software PPM-Decoder and SMART-PPM-Decoder Version 1.0
' Decodes a 1 to 8-channel RC-sum signal (PPM) for direct servo-control.
' To the servo-output is the pulse signal (1ms to 2ms).
' CPU: ATtiny44V (DIP/SOIP)
' Clock: RC-Internal Oscillator 8MHz / 8 (System-Clock = 1MHz)
' Compiler: 1.11.9.2
' Source: Version 1.0
' Author: M. Ruhwald 2008 (www.MitchSoft.de)
' Created: 11.07.2008
' Last change: 03.08.2008
' Resources:
' INT0 - RC-PPM signal (Input)
' OC1A - Interrupt (PPM-Timeout)
' OC1B - Interrupt (Frame-Start)
' Timer1 - Counter (1MHz)
' Pinning:
' PortA - Servo Outputs channel 1 to 8
' PortB.0 - LED (red for error); non-SMART version
' PortB.1 - LED (yellow blink for receiving), non-Smart Version
' PortB.2 - Input PPM-Signal
' PortB.3 - Reset
' ---------------------------------------------------------------------------------------
' FUNCTIONAL DESCRIPTION
' Principle:
' Timer1 is configured as a counter. It is clocked with a clock of 1.0 MHz.
' This per clock a time of 1.0 microseconds elapses.
' The Timer1 causes two interrupts, namely OC1A and OC1B.
' OC1A is used to
' to identify a missing PPM signal. The value is set to RC_Timeout,
' and corresponds to a time of 50 milli-seconds. If during this time, no edges
' detected on the INT0 input, the interrupt is triggered and calls the routine _ISR_INT0.
' The timer is automatically reset to zero.
' OC1B is used to detect the start signal of a pulse train. The value for
' Compare1B is set to RC_Frame and corresponds to a time of 2.5 milli-seconds.
' If at this time no edge occurs, the interrupt occurs and the routine
' _ISR_OC1B called.
' The RC-sum signal (PPM) ICP1 the input is supplied. For each negative edge
' a ICP1 interrupt triggered.
' ICP1 Interrupt:
' In the ICP1 the Timer1 interrupt routine is set to 0 and increase the channel count by 1.
' Then the channel pulses are issued. Finally, will offer a status bits
' in the variable status flags (byte) set.
' If a start is detected, the channel counter (RC_ChannelNr) is set to 1.
' If no start signal is detected, the channel counter is incremented by 1. Thereafter, the
' selected channel (RC_ChannelNr) connected and the previously activated off.
' If more than 8 channels (PPM) are transmitted, the channel count is increased further.
' On the channel outputs but only a maximum of 8 channels are decoded.
' If less than 8 channels (PPM) are transmitted, the channel counter is displayed,
' And it will be produced at the outputs of any other stimulus.
' -----------------------------------------------
' MCU - Configuration
' -----------------------------------------------
$regfile = "attiny44.dat"
$Crystal = 1000000 ' internal clock
$hwstack = 60
$swstack = 60
$framesize = 60
' -----------------------------------------------
' Variables / Constants
' -----------------------------------------------
const RC_Frame = 2500 ' Threshold (counter value) for the detection of the start pulse (2.5 ms)
const RC_Timeout = 50000 ' Timeout for missing PPM-Signal (0,1s)
dim RC_ChannelNr as byte ' current output channel
dim StatusFlags as byte ' Status-Flags
const ppm_FrameStart = 0 ' New frame begins at the earliest edge
const ppm_Trigger = 1 ' Trigger-edge (rising) an INT0
const ppm_Timeout = 2 ' no edges of INT0
' -----------------------------------------------
' Define Ports for channels 1 to 8
' -----------------------------------------------
' Name for the outputs
ddra = &b11111111 ' PortA.0 to PortA.7 as Output
RC_Channel1 Alias porta.0
RC_Channel2 Alias porta.1
RC_Channel3 Alias Porta.2
RC_Channel4 Alias Porta.3
RC_Channel5 Alias Porta.4
RC_Channel6 Alias Porta.5
RC_Channel7 Alias Porta.6
RC_Channel8 Alias Porta.7
' -----------------------------------------------
' Ports configuration for LEDs
' -----------------------------------------------
' Red LED
LED_Error Alias Portb.0 ' LED indicator: no PPM signal to ICP1
config LED_Error = output
'LED_Error = 1 ' LED off
' Yellow LED
LED_Signal Alias Portb.1
config LED_Signal = output
'LED_Signal = 1 ' LED off
' -----------------------------------------------
' Timer1 configuration
' -----------------------------------------------
config timer1 = Counter , prescale = 1 , Clear timer = 1 ' Clock: 1000kHz
compare1b = RC_Frame ' Frame-Detection (2,5ms)
compare1a = RC_Timeout ' Timeout for no PPM-Signal (50ms)
start timer1
' -----------------------------------------------
' Interrupts konfigurieren
' -----------------------------------------------
config INT0 = RISING ' INT0 as PPM-Input (rising edge)
on int0 _ISR_INT0 ' Interrupt-Routine
enable int0 ' Interrupt activated
on oc1a _ISR_OC1A ' Frame-Timeout (50ms)
enable oc1a ' Frame-Interrupt enabled
on oc1b _ISR_OC1B ' Frame-Detection (2,5ms)
enable oc1b ' Frame-Detection enabled
' Connected LEDs off after initialization
' (non-smart version)
wait 1
LED_Error = 1 ' Red LED off
waitms 500
LED_Signal = 1 ' Yellow LED off
enable interrupts ' Global Interrupts enabled
' -----------------------------------------------
' M A I N L O O P
' -----------------------------------------------
do
' Evaluate Status flags
' LED-Error toggle on Frame-Timeout
if StatusFlags.ppm_Timeout = 1 then
toggle LED_Error ' red LED to blink
StatusFlags.ppm_Timeout = 0 ' Flag reset
LED_Signal = 1 ' LED-Signal on
end if
' When detected trigger signals LED-off Error
'and the LED signal is turned on permanently
if StatusFlags.ppm_Trigger = 1 then ' Trigger pulses detected
LED_Error = 1 ' Red LED Off
StatusFlags.ppm_Trigger = 0
LED_Signal = 0
end if
loop
end
' -----------------------------------------------
' Interrupt routines
' -----------------------------------------------
' Interrupt is called every negative edge at input ICP1
_ISR_INT0:
Timer1 = 0 ' Timer1 set to 0
incr RC_ChannelNr
select case RC_ChannelNr ' Channel - Pulse output
case 1
RC_Channel1 = 1 ' Channel 1 On
case 2
RC_Channel1 = 0 ' Channel 1 Off
RC_Channel2 = 1 ' Channel 2 On
case 3
RC_Channel2 = 0 ' Channel 2 Off
RC_Channel3 = 1 ' Channel 3 On
case 4
RC_Channel3 = 0 ' Channel 3 Off
RC_Channel4 = 1 ' Channel 4 On
case 5
RC_Channel4 = 0 ' Channel 4 Off
RC_Channel5 = 1 ' Channel 5 On
case 6
RC_Channel5 = 0 ' Channel 5 Off
RC_Channel6 = 1 ' Channel 6 On
case 7
RC_Channel6 = 0 ' Channel 6 Off
RC_Channel7 = 1 ' Channel 7 On
case 8
RC_Channel7 = 0 ' Channel 7 Off
RC_Channel8 = 1 ' Channel 8 On
case else
RC_Channel8 = 0 ' Channel 8 Off
end select
StatusFlags.ppm_Trigger = 1 ' Trigger edge is detected (rising INT0)
Return
' Frame Detection (Startpulse > 2,5ms)
_ISR_OC1B:
RC_ChannelNr = 0 ' Channel counter to 0
StatusFlags.ppm_FrameStart = 1 ' Status flag new frame begins with the next edge
Return
' Timeout (no PPM-Signal; 50ms)
_ISR_OC1A:
StatusFlags.ppm_Timeout = 1 ' timeout within no PPM signal
Return
NF wrote:= pake beberapa servo tester untuk gerakin : drive motor , diving plane , rudder dan camera .....
simple nya , dari handheld controller cuma perlu kabel isi 6 , 2 kabel untuk catudaya tester (kalo pake batere dari ROV) dan 4 kabel buat servo control. jumlah kabel bisa bertambah kalo buat kirim gambar video ke monitor diatas.
todiahmad wrote:
Pak. servo tester itu bisa untuk maju mundur esc ya? posisi tengah itu off, kemudian kanan maju, kiri reverse?
thanks buat masukannya..
NF wrote:knapa ga minta tolong sama suhu coyo saja ??
NF wrote:knapa ga minta tolong sama suhu coyo saja ??