Raifuru.
Level 5
Level 4
Level 3
Level 2
Level 1
- 30 Oct. 2011
- 616
- 0
- 442
J'en sais rien je l'ai pas payé ( Frais de l'unif ) Mais demande à tes parents généralement un truc "éducatif" pour nowel il ne dise jamais non .

-- start button
alias start_main is pin_A4
pin_A4_direction = input
--
include delay
--
include print
--
include format
-- Moteur
Alias Moteur1 is pin_C2 --Moteur droit
Alias Moteur2 is pin_C1 --Moteur gauche
Alias Sens1 is pin_D0 --Avance moteur gauche
Alias Sens2 is pin_D1 --Recule moteur gauche
Alias Sens3 is pin_B1 --Avance moteur droit
Alias Sens4 is pin_B2 --Recule moteur droit
pin_C2_direction = output
pin_C1_direction = output
pin_D0_direction = output
pin_D1_direction = output
pin_B1_direction = output
pin_B2_direction = output
--
forever loop
Sens1 = on
Sens3 = on
Sens2 = off
Sens4 = off
Moteur1 = on
Moteur2 = on
delay_1ms(5000)
Sens1 = on
Sens3 = on
Sens2 = off
Sens4 = off
Moteur1 = off
Moteur2 = on
delay_1ms(666)
Moteur1 = on
Moteur2 = on
delay_1ms(5000)
Sens1 = on
Sens3 = on
Sens2 = off
Sens4 = off
Moteur1 = off
Moteur2 = on
delay_1ms(666)
Moteur1 = on
Moteur2 = on
delay_1ms(5000)
Sens1 = on
Sens3 = on
Sens2 = off
Sens4 = off
Moteur1 = off
Moteur2 = on
delay_1ms(666)
Moteur1 = on
Moteur2 = on
delay_1ms(5000)
end loop
Malgré que je n'y connais rien dans ce langage de prog ont peux voir que tu le fait tourner en boucle sur différent axe (activation/désactivation des moteurs avancer/reculé 1 seul moteur pour qu'il puisse tourner,
tous ça dans la boucle et parsemé de délais plus ou moins important) ça a l'air simple en vrais fin plus simple que je ne pensais ^^
Je suis en train de le programmer , j'ai quelques soucis avec le capteur qui détecte le premier objet et ensuite plus rien , il s'arrête plus et il tourne sur lui même ....
J'utilise un télémètre , un capteur qui vois un objet à 32 cm de distance en 10 Bits.
Proteus est un très bon programme , au contraire je les sur mon pc portable , mais j'ai pas le temps de simuler , je préfère le faire direct sur le robot .
Variable .
---------- Message ajouté à 22h21 ---------- Le message précédent était à 22h20 ----------
Enfin je pense qu'il peut faire les deux , perso je test la variable qui est plus explicite pour ma part .
[M]inCrash;1102265 à dit:C'est cool :o sauf la programmation mdr
[M]inCrash;1102265 à dit:C'est cool :o sauf la programmation mdr

-------------------------- Robot télécommandé---------------------------
-- Réalisé par Censuré
-- Projet Informatique 1EMS : Henallux.
-- 2012-2013
------------------------------------------------------------------------
include 16f887 -- target PICmicro
--
-- This program assumes that a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
pragma target clock 20_000_000 -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC HS -- HS crystal or resonator
pragma target WDT disabled -- no watchdog
pragma target LVP disabled -- no Low Voltage Programming
pragma target MCLR external -- reset externally
-- These configuration bit settings are only a selection, sufficient for
-- this program, but other programs may need more or different settings.
--
enable_digital_io() -- make all pins digital I/O
--
--
alias led3 is pin_B3
pin_B3_direction = output
-- Config LCD
--
const byte LCD_ROWS = 2 -- LCD with 2 lines
const byte LCD_CHARS = 16 -- and 16 characters per line
--
alias lcd_en is pin_D3 -- data trigger
alias lcd_rs is pin_D2 -- command/data select.
--
pin_D3_direction = output
pin_D2_direction = output
--
alias lcd_d4 is pin_D4
alias lcd_d5 is pin_D5
alias lcd_d6 is pin_D6
alias lcd_d7 is pin_D7
--
pin_D4_direction = output
pin_D5_direction = output
pin_D6_direction = output
pin_D7_direction = output
--
include lcd_hd44780_4
--
lcd_init() -- init the lcd controller
-- Config ADC
const Left_ZX_03 = 0 -- AN0 (pin_A0)
const Right_ZX_03 = 1 -- AN1 (pin_A1)
const GP2D120 = 2 -- AN2 (pin_A2)
const pot = 3 -- AN3 (pin_A3)
const byte ADC_NVREF = 0 -- no external Vref
const word ADC_RSOURCE = 10_000 -- 10K potmeter
const bit ADC_HIGH_RESOLUTION = TRUE -- high resolution
include adc -- include ADC library
adc_init() -- init library
set_analog_pin(Left_ZX_03) -- init used ADC channel
set_analog_pin(Right_ZX_03) -- init used ADC channel
set_analog_pin(GP2D120) -- init used ADC channel
set_analog_pin(pot) -- init used ADC channel
-- Config Zx_IRM sensor
alias Zx_IRM is pin_B0
pin_B0_direction = input
const byte txt5[LCD_CHARS] = " ER-4 Remote "
var byte ir_cmd = 0
var byte key
-- Interrupt service routine INT
procedure pin_b0_interrupt is
pragma interrupt
if (INTCON_INTF) then
_usec_delay(416) -- Delay 1/2 of 1 bit timing(baudrate 1200 bps)
for 8 loop -- Loop for 8 time for keep data from ER-4 Remote
_usec_delay(833) -- Delay of 1 bit timing(baudrate 1200 bps)
ir_cmd = ir_cmd >> 1 -- Shitt bit 1 time
if((PORTB & 0x01)==1) then -- Get logic @ RB0 = '1'?
ir_cmd = ir_cmd | 0x80 -- Inset bit data is '1'
end if
end loop
_usec_delay(833) -- Delay of 1 bit timing(baudrate 1200 bps)
INTCON_INTF= 0 -- clear intf to re-enable pin b0 interrupts
end if
end procedure
option_reg = 0b_1000_0000 -- disable pull-up and high-low edge detect
intcon = 0b_1001_0000 -- enable interrupts general and port B
--
-- Function for get character from Remote
function get_remote( ) return byte is
var byte key
key=ir_cmd -- Get character to buffer
ir_cmd = 0 -- Clear old data
return key -- Return character from Remote
end function
-- start button
alias start_main is pin_A4
pin_A4_direction = input
--
include delay
--
include print
--
include format
-- Variables
var byte Left_ZX
var byte Right_ZX
var byte GP2D_120
var byte measure
var byte dutycycle
var bit go = 0
-- LCD strings
const byte txt1[LCD_CHARS] = " ROBOPICA "
const byte txt2[LCD_CHARS] = " Pic 16F887 "
const byte txt3[LCD_CHARS] = " Pour demarrer "
const byte txt4[LCD_CHARS] = "Appuyer sur RA4 "
lcd_cursor_position(0,0)
print_string(lcd, txt1)
lcd_cursor_position(1,0)
print_string(lcd, txt2)
delay_1ms (2000)
lcd_cursor_position(0,0)
print_string(lcd, txt3)
lcd_cursor_position(1,0)
print_string(lcd, txt4)
const byte txt6[LCD_CHARS] = " Button A Press "
const byte txt7[LCD_CHARS] = " Button B Press "
const byte txt8[LCD_CHARS] = " Button C Press "
const byte txt9[LCD_CHARS] = " Button D Press "
-- Moteur
Alias Moteur1 is pin_C2 --Moteur droit
Alias Moteur2 is pin_C1 --Moteur gauche
Alias Sens1 is pin_D0 --Avance moteur gauche
Alias Sens2 is pin_D1 --Recule moteur gauche
Alias Sens3 is pin_B1 --Avance moteur droit
Alias Sens4 is pin_B2 --Recule moteur droit
pin_C2_direction = output
pin_C1_direction = output
pin_D0_direction = output
pin_D1_direction = output
pin_B1_direction = output
pin_B2_direction = output
Moteur1 = off
Moteur2 = off
forever loop
if pin_A4 == 0 then
go = 1
lcd_cursor_position(0,0)
print_string (lcd,txt5) -- Display message ER-4 Remote
end if
if go == 1 then
key = get_remote() -- Get Remote
if(key == "a" | key == "A") then -- Boutton "A" pressé, en arrière
Moteur1 = on
Moteur2 = on
Sens1 = off
Sens2 = on
Sens3 = off
Sens4 = on
delay_1ms(50)
end if
if(key == "b" | key == "B") then -- Boutton "B" pressé, à droite
Moteur1 = on
Moteur2 = on
Sens1 = on
Sens2 = off
Sens3 = off
Sens4 = on
delay_1ms(50)
end if
if(key == "c" | key == "C") then -- Boutton "C" pressé, à gauche
Moteur1 = on
Moteur2 = on
Sens1 = off
Sens2 = on
Sens3 = on
Sens4 = off
delay_1ms(50)
end if
if(key == "d" | key == "D") then -- Boutton "D" pressé, en avant
Moteur1 = on
Moteur2 = on
Sens1 = on
Sens2 = off
Sens3 = on
Sens4 = off
delay_1ms(50)
end if
if key == 0 then
Moteur1 = off
Moteur2 = off
end if
end if
end loop