Find Jobs
Hire Freelancers

Basic programming of Atmel AVR ATmega168 microcontroller

$30-100 USD

En curso
Publicado hace más de 13 años

$30-100 USD

Pagado a la entrega
I need to finish a version of this project with a couple of tweaks. [login to view URL] First one is to remove the excite outputs from the mcu, so I can excite the bridge straight from the 5v rail. If this is successful there are a few other mods that need to be made. First post so I thought I'd keep it simple to start. Cheers Alan UK ## Deliverables Remove output PD3 & 4 +/- alternating excite voltages from program (bridge will be excited from 5v rail) Current code // weighscale.c // for NerdKits with ATmega168 #define F_CPU 14745600 #include #include #include #include #include #include "../libnerdkits/delay.h" #include "../libnerdkits/lcd.h" #include "../libnerdkits/uart.h" // PIN DEFINITIONS: // PC0 -- analog in // // PD4 - bridge excite // PD3 - bridge excite void adc_init() { // set analog to digital converter // for external reference (5v), single ended input ADC0 ADMUX = 0; // set analog to digital converter // to be enabled, with a clock prescale of 1/128 // so that the ADC clock runs at 115.2kHz. ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); // fire a conversion just to get the ADC warmed up ADCSRA |= (1<<ADSC); } uint16_t adc_read() { // set ADSC bit to get the *next* conversion started ADCSRA |= (1<<ADSC); // read from ADC, waiting for conversion to finish // wait for it to be cleared while(ADCSRA & (1<<ADSC)) { // do nothing... just hold your breath. } // bit is cleared, so we have a result. // read from the ADCL/ADCH registers, and combine the result // Note: ADCL must be read first (datasheet pp. 259) uint16_t result = ADCL; uint16_t temp = ADCH; result = result + (temp<<8); return result; } int main() { // set PD3, PD4 as outputs DDRD |= (1<<PD3) | (1<<PD4); // init ADC adc_init(); // init serial port uart_init(); FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW); stdin = stdout = &uart_stream; int16_t reading; while(1) { // set polarity +- PORTD |= (1<<PD3); PORTD &= ~(1<<PD4); // wait 5 time constants (bw=12kHz, T=13.2us) delay_us(66); // take reading //reading = adc_read(); printf_P(PSTR("%d "), adc_read()); // set polarity -+ PORTD |= (1<<PD4); PORTD &= ~(1<<PD3); // wait 5 time constants (bw=12kHz, T=13.2us) delay_us(66); // take reading //reading = reading - adc_read(); printf_P(PSTR("%d\r\n"), adc_read()); // send over serial port //printf_P(PSTR("%d\r\n"), reading); } return 0; } ## Platform MCU is ATmega168
ID del proyecto: 3745378

Información sobre el proyecto

5 propuestas
Proyecto remoto
Activo hace 14 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
See private message.
$17 USD en 14 días
3,9 (10 comentarios)
4,1
4,1
5 freelancers están ofertando un promedio de $87 USD por este trabajo
Avatar del usuario
See private message.
$85 USD en 14 días
4,9 (6 comentarios)
4,1
4,1
Avatar del usuario
See private message.
$212,50 USD en 14 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
See private message.
$34 USD en 14 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
See private message.
$85 USD en 14 días
0,0 (1 comentario)
0,0
0,0

Sobre este cliente

Bandera de UNITED KINGDOM
Fowey, United Kingdom
5,0
6
Miembro desde sept 23, 2010

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.