2 pièce(s) jointe(s)
Programmer avec un ATMEGA 8515 : petit projet industriel
Bonjour,
Je suis acutellement en stage dans le cadre de ma 1ère année de BTS système électronique et j'ai donc un projet à traiter.
Mon projet consiste à éviter les remplacement systématiques sur des freins à disque. Au départ après avoir lu la documentation constructeur des freins, j'ai réflechi à ce que j'allais faire comme circuit electronique mais au final j'ai opté pour la solution d'un microcontroleur mais le seul souci c'est la syntaxe du programme pour moi , je sais ce que je veux faire à partir du signal qui m'est donné mais je n'arrive pas à l'écrire;(.
Si vous avez une idée, j'ai déja créer un début de programme :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/*****************************************************
This program was produced by the
CodeWizardAVR V1.25.7a Evaluation
Automatic Program Generator
© Copyright 1998-2007 Pavel Haiduc, HP InfoTech s.r.l.
<a href="http://www.hpinfotech.com" target="_blank">http://www.hpinfotech.com</a>
Project :
Version :
Date : 05/06/2009
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : ATmega8515
Program type : Application
Clock frequency : 8,000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 128
*****************************************************/
#include <mega8515.h>
#include <delay.h>
#include <math.h>
#include <time.h>
#define freinV ~PINA
#define imageI ~PINA
#define convertiV ~PINA
#define economiV ~PINA
#define ledV ~PINB
#define ledR ~PINB
#define ledO ~PINB
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=In
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=T
PORTA=0x00;
DDRA=0xFE;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;
// Port C initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTC=0x00;
DDRC=0xFF;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTD=0x00;
DDRD=0xFF;
// Port E initialization
// Func2=Out Func1=Out Func0=Out
// State2=0 State1=0 State0=0
PORTE=0x00;
DDRE=0x07;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
EMCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
while (1)
{
// Place your code here
if((freinV=2) && (imageI=3)) {ledO=1}
else{ledR=1 && return progprinc}
On retourne au proprinc
time_10ms
(economi==10)? ledV=1:ledR=1
};
} |
Voila pour le moment ce que j'ai pu faire seul . Il me manque essentiellement le timer pour pouvoir déterminer la pente ...!!!