Tutorial – BeagleBone Black: Conversão Analógico-Digital

On 15 de abril de 2014 by Fabio Oliveira de Paula

Este artigo tem por objetivo descrever as etapas de utilização do conversor analógico-digital (ADC) na BeagleBone Black (BBB) com o Sistema Operacional (SO) Angstrom. Serão apresentados os comandos para o terminal e um circuito simples de aquisição da luminosidade em um ambiente controlado por um código-exemplo em C.

O exemplo utilizado, tanto o código quanto o circuito, são de simples implementação para focarmos no procedimento. Novos projetos futuros mais elaborados poderão utilizar esses mesmos procedimentos descritos.

A linguagem abordada nesse tutorial será C. Com nosso código, seremos capazes de fazer a leitura do valor analógico do pino AIN1 da BBB, sua conversão para digital e exibição no terminal.

HARDWARE DO ADC DA BEAGLEBONE BLACK

Propriedades:

– Tamanho do valor convertido: 12 bits (valores de saída na faixa de 0-4095)
– Tempo da amostragem: 125ns
– Intervalo de tensão de entrada: de 0 a 1,8V (IMPORTANTE!! Não ultrapassar!)
– A corrente que flui para o pino ADC nessa faixa de operação é de 2uA.
– Uma vez que se realizam medições em milivolts, com tolerância de erro de 0,1% nos resistores, deve ser utilizado um divisor de tensão.
– Se estiver usando um divisor de tensão, o resistor conectado ao terra deve ser menor ou igual a 1kohm. Esse circuito de divisor de tensão será utilizado como exemplo desse tutorial.
– A BBB fornece tensão de referência de 1,8V na porta VDD_ADC – pino 9_32 e terra (GND) na porta GNDA_ADC – pino 9_34.

Pinagem:

Tabela 1. Pinagem e descrição do ADC da BBB

Nome

Pino

Pino

Nome

P9_32

VDD_ADC

AIN4

P9_33

P9_34

GNDA_ADC

AIN6

P9_35

P9_36

AIN5

AIN2

P9_37

P9_38

AIN3

AIN0

P9_39

P9_40

AIN1

EXEMPLO PRÁTICO na beaglebone black

Com o objetivo de ilustrar esse tutorial, implementaremos um circuito capaz de medir a intensidade de luz em um ambiente. Para isso, necessitaremos de um sensor LDR, um resistor de 1Kohms e um protoboard (matriz de contatos).

A tensão de 1,8V é obtida diretamente no pino 9_32 (VDD_ADC) da BBB. A saída o sensor LDR é ligada ao resistor de 1kohm e derivada para a entrada analógica da BBB no pino 9_40 (AIN1). O outro terminal do resistor é conectado ao terra (GND) pelo no pino 9_34 (GNDA_ADC). O esquemático dessas ligações é apresentado na figura 1 e um layout para auxiliar o entendimento, na figura 2. Execute a montagem do circuito.

analog_1

analog_2

Leitura do valor analógico

Primeiramente, utilizaremos um código sem biblioteca. Crie um arquivo com o nome adc_bbb_sem_bibliot.c (sugestão)e copie para ele o código abaixo:

adc_bbb_sem_bibliot.c

[sourcecode language=”c”]
#include <stdio.h>
#include <time.h>

void pauseSec(int sec);

int main()
{
FILE *ain,*aval;
int value,i;

ain = fopen("/sys/devices/bone_capemgr.8/slots", "w");
fseek(ain,0,SEEK_SET);
fprintf(ain,"cape-bone-iio");
fflush(ain);

while(1)
{
aval = fopen("/sys/devices/ocp.2/helper.14/AIN0", "r");
fseek(aval,0,SEEK_SET);
fscanf(aval,"%d",&value);
fclose(aval);

for(i = 0; i<1000000;i++);

printf("value: %d : %d\n",value);
for(i = 0; i<1000000;i++);
}
fclose(ain);
return 0;
}

void pauseSec(int sec)
{
time_t now,later;

now = time(NULL);
later = time(NULL);

while((later – now) < (double) sec)
later = time(NULL);
}
[/sourcecode]

O procedimento de compilação e execução de projetos na BBB são descritos no tutorial Procedimentos para compilação e execução na BBB.

Agora trabalharemos com o código utilizando a biblioteca libBBB. Além de trabalhar com conversão AD, ela pode ser usada também para projetos com PWM, USART, I2C, controle de GPIOs, SPI, LCD e timers. Para isso, crie três arquivos com os nomes adc_bbb.c (sugestão), libBBB.c e libBBB.h. Os arquivos libBBB devem ter necessariamente esse nome para não ser preciso alterar o código.

adc_bbb.c

[sourcecode language=”c”]
#include "libBBB.h"

#define INIT 8 // para inicializar o conversor AD
#define READ 14 // para ler o valor convertido

int main()
{
int value;
initADC(INIT);
while(1)
{
value = readADC(READ, AIN0);
pauseNanoSec(100000);
printf("value: %d \n",value);
}
return 0;
}
[/sourcecode]

LibBBB.c

[sourcecode language=”c”]
#include "libBBB.h"

//Local functions not used by outside world
int checkOverlay(char *file);
void initCMD(unsigned char cmd);

//*************************************************
//* Device Tree Overlay *
//*************************************************
int addOverlay(char *dtb, char *overname)
{
char file[100];

sprintf(file,"/lib/firmware/%s",dtb);

printf("Check for dtbo file: ");
if(checkOverlay(file) == 0)
{
//check current directory for file
char temp[100];
sprintf(temp,"%s",dtb);

if((access(temp,F_OK)) < 0)
{
printf("The file isn’t here either\n");
exit(1);
}
else
{
printf("Found file\n");
printf("Copying to correct folder\n");

FILE *f,*fnew;
long num;
char *fileread;
size_t result;

f = fopen(temp,"r");
if(f == NULL)
{
printf("temp failed to open\n");
exit(1);
}

fnew = fopen(file,"w");
if(fnew == NULL)
{
printf("file failed to open\n");
exit(1);
}

fseek(f,0,SEEK_END);
fseek(fnew,0,SEEK_SET);
num = ftell(f);
rewind(f);

fileread = (char*) malloc(sizeof(char)*num);
if(fileread == NULL)
{
printf("Memory error\n");
exit(1);
}

result = fread(fileread,1,num,f);
if(result != num)
{
printf("Error reading file\n");
exit(1);
}

fwrite(fileread,sizeof(char),sizeof(fileread),fnew);
fclose(f);
fclose(fnew);

//Now file should be there so double check
if(checkOverlay(file) == 0)
{
printf("This just isn’t working\n");
exit(1);
}
}

}

//If you made it here then the dtbo file exists now we need to check
//if it is already applied or not, then add it if it isn’t there, or
//if it is already applied then we did all of this for nothing

FILE *over;
char ch[200] = {0};
const char *pch = &ch[0];
char *search;
int ch2 = 0;
int j;
//char strsearch[] = "uart";

over = fopen("/sys/devices/bone_capemgr.8/slots", "r");
if(over == NULL)
{
printf("File didn’t open\n");
exit(1);
}

fseek(over,0,SEEK_SET);

while(ch2 != -1)
{
//find all the overlays
j = 0;
while(ch2 != ‘\n’)
{
ch2 = fgetc(over);
if(ch2 == ‘\n’)
break;
ch[j] = (char) ch2;
j++;
}

printf("%s\n",ch);

//now look for the specific overlay
search = strstr(pch,overname);
if(search == NULL)
{
printf("Search: Failed\n");
}
else
{
printf("Search: Found\n");
return 0;
}

ch2 = fgetc(over);

}

fclose(over);

//ok if you made it here then you search them all and it would
//appear that it isn’t there, so it is now time to add it
char name[100];
sprintf(name, "%s",overname);

over = fopen("/sys/devices/bone_capemgr.8/slots", "w");
if(over == NULL) printf("File didn’t open\n");
fseek(over,0,SEEK_SET);
fprintf(over,name);
fflush(over);
fclose(over);

printf("Overlay Added\n");
return 0;
}

int checkOverlay(char *file)
{
int found = 0;

if((access(file,F_OK)) < 0)
{
printf("Failed\n");
found = 0;
}
else
{
printf("Success\n");
found = 1;
}
return found;
}

//*************************************************
//* USR FUNCTIONS *
//*************************************************
int setUsrLedValue(char* led, int value)
{
FILE *usr;
char buf[20];
char buf2[50] = "/sys/class/leds/beaglebone:green:";

//build file path to usr led brightness
sprintf(buf,"%s",led);
strcat(buf2,strcat(buf,"/brightness"));

usr = fopen(buf2, "w");
if(usr == NULL) printf("USR Led failed to open\n");
fseek(usr,0,SEEK_SET);
fprintf(usr,"%d",value);
fflush(usr);
fclose(usr);

return 0;
}

//*************************************************
//* GPIO FUNCTIONS *
//*************************************************
int initPin(int pinnum)
{
FILE *io;

io = fopen("/sys/class/gpio/export", "w");
if(io == NULL) printf("Pin failed to initialize\n");
fseek(io,0,SEEK_SET);
fprintf(io,"%d",pinnum);
fflush(io);
fclose(io);

return 0;
}

int setPinDirection(int pinnum, char* dir)
{
FILE *pdir;
char buf[10];
char buf2[50] = "/sys/class/gpio/gpio";

//build file path to the direction file
sprintf(buf,"%i",pinnum);
strcat(buf2,strcat(buf,"/direction"));

pdir = fopen(buf2, "w");
if(pdir == NULL) printf("Direction failed to open\n");
fseek(pdir,0,SEEK_SET);
fprintf(pdir,"%s",dir);
fflush(pdir);
fclose(pdir);

return 0;
}

int setPinValue(int pinnum, int value)
{
FILE *val;
char buf[5];
char buf2[50] = "/sys/class/gpio/gpio";

//build path to value file
sprintf(buf,"%i",pinnum);
strcat(buf2,strcat(buf,"/value"));

val = fopen(buf2, "w");
if(val == NULL) printf("Value failed to open\n");
fseek(val,0,SEEK_SET);
fprintf(val,"%d",value);
fflush(val);
fclose(val);

return 0;
}

int getPinValue(int pinnum)
{
FILE *val;
int value;
char buf[5];
char buf2[50] = "/sys/class/gpio/gpio";

//build file path to value file
sprintf(buf,"%i",pinnum);
strcat(buf2,strcat(buf,"/value"));

val = fopen(buf2, "r");
if(val == NULL) printf("Input value failed to open\n");
fseek(val,0,SEEK_SET);
fscanf(val,"%d",&value);
fclose(val);

return value;
}

//*************************************************
//* PWM FUNCTIONS *
//*************************************************
int initPWM(int mgrnum, char* pin)
{
FILE *pwm;
char buf[5];
char buf2[50] = "/sys/devices/bone_capemgr.";
char buf3[20] = "bone_pwm_";

//build file paths
sprintf(buf,"%i",mgrnum);
strcat(buf2,strcat(buf,"/slots"));

strcat(buf3,pin);

pwm = fopen(buf2, "w");
if(pwm == NULL) printf("PWM failed to initialize\n");
fseek(pwm,0,SEEK_SET);
fprintf(pwm,"am33xx_pwm");
fflush(pwm);
fprintf(pwm,"%s",buf3);
fflush(pwm);
fclose(pwm);

return 0;
}

int setPWMPeriod(int helpnum, char* pin, int period)
{
FILE *pwm;
char buf[5];
char buf2[60] = "/sys/devices/ocp.2/pwm_test_";

//build file path
sprintf(buf,"%i",helpnum);
printf("%s\n",pin);
strcat(buf2,pin);
strcat(buf2,".");
strcat(buf2,strcat(buf,"/period"));

printf("%s\n",buf2);
pwm = fopen(buf2, "w");
if(pwm == NULL) printf("PWM Period failed to open\n");
fseek(pwm,0,SEEK_SET);
fprintf(pwm,"%d",period);
fflush(pwm);
fclose(pwm);

return 0;
}

int setPWMDuty(int helpnum, char* pin, int duty)
{
FILE *pwm;
char buf[5];
char buf2[50] = "/sys/devices/ocp.2/pwm_test_";

//build file path
sprintf(buf,"%i",helpnum);
strcat(buf2,pin);
strcat(buf2,".");
strcat(buf2,strcat(buf,"/duty"));

pwm = fopen(buf2, "w");
if(pwm == NULL) printf("PWM Duty failed to open\n");
fseek(pwm,0,SEEK_SET);
fprintf(pwm,"%d",duty);
fflush(pwm);
fclose(pwm);

return 0;
}

int setPWMOnOff(int helpnum, char* pin, int run)
{
FILE *pwm;
char buf[5];
char buf2[50] = "/sys/devices/ocp.2/pwm_test_";

//build file path
sprintf(buf,"%i",helpnum);
strcat(buf2,pin);
strcat(buf2,".");
strcat(buf2,strcat(buf,"/run"));

pwm = fopen(buf2, "w");
if(pwm == NULL) printf("PWM Run failed to open\n");
fseek(pwm,0,SEEK_SET);
fprintf(pwm,"%d",run);
fflush(pwm);
fclose(pwm);

return 0;
}

//*************************************************
//* UART FUNCTIONS *
//*************************************************
int initUART(int mgrnum, char* uartnum)
{
//return the int reference to the port
struct termios old;
struct termios new;
int fd;

fd = open("/dev/ttyO4", O_RDWR | O_NOCTTY);
if(fd < 0)
{
printf("Port failed to open\n");
return fd;
}

tcgetattr(fd,&old);
bzero(&new, sizeof(new));

new.c_cflag = B4800 | CS8 | CLOCAL | CREAD;
new.c_iflag = IGNPAR | ICRNL;
new.c_oflag = 0;
new.c_lflag = 0;

new.c_cc[VTIME] = 0;
new.c_cc[VMIN] = 1;

//clean the line and set the attributes
tcflush(fd,TCIFLUSH);
tcsetattr(fd,TCSANOW,&new);

return fd;
}

void closeUART(int fd)
{
close(fd);
}

int configUART(UART u, int property, char* value)
{
//This is used to set the configuration values
//for the uart module

return 0;
}

int txUART(int uart, unsigned char data)
{
//write a single byte

write(uart,&data,1);
tcdrain(uart);

return 0;
}

unsigned char rxUART(int uart)
{
//read in a single byte
unsigned char data;

read(uart,&data,1);
return data;
}

int strUART(int uart, char* buf)
{

int i;

for(i=0; i < strlen(buf); i++)
txUART(uart,buf[i]);

return 0;
}

//*************************************************
//* I2C FUNCTIONS *
//*************************************************
int initI2C(int modnum, int addr)
{
int device;

//open the i2c file
device = open("/dev/i2c-1", O_RDWR);
if(device < 0)
{
printf("I2C module didn’t open\n");
return -1;
}

//acquire the bus
if(ioctl(device, I2C_SLAVE, addr) < 0)
{
printf("Failed to get I2C bus\n");
return -1;
}

return device;
}

void closeI2C(int device)
{
close(device);
}

int writeByteI2C(int device, unsigned char *data)
{
if(write(device, data, 1) != 1)
{
printf("Error occurred during I2C write\n");
return -1;
}

return 0;
}

int writeBufferI2C(int device, unsigned char *buf, int len)
{
if(write(device,buf,len) != len)
{
printf("Error occurred during I2C buffer write\n");
return -1;
}

return 0;
}

int readByteI2C(int device, unsigned char *data)
{
if(read(device,&data,1) != 1)
{
printf("Error occurred during I2C read\n");
return -1;
}

return 0;
}

int readBufferI2C(int device, int numbytes, unsigned char *buf)
{
if(read(device, &buf, numbytes) != numbytes)
{
printf("Error occurred during I2C buffer read\n");
return -1;
}

return 0;
}

//*************************************************
//* SPI FUNCTIONS *
//*************************************************
int initSPI(int modnum)
{
int device;

device = open("/dev/spidev1.0", O_RDWR);
if(device < 0)
{
printf("SPI file failed to open\n");
return -1;
}

return device;
}

void closeSPI(int device)
{
close(device);
}

int writeByteSPI(int device, unsigned char* data)
{
if(write(device, data, 1) != 1)
{
printf("Error occurred during SPI write\n");
return -1;
}

return 0;
}

int writeBufferSPI(int device, unsigned char *buf, int len)
{
if(write(device, buf, len) != len)
{
printf("Error occurred during buffer SPI write\n");
return -1;
}

return 0;
}

int readByteSPI(int device, unsigned char* data)
{
if(read(device, &data, 1) != 1)
{
printf("Error occurred during SPI read\n");
return -1;
}
return 0;
}

int readBufferSPI(int device, int numbytes, unsigned char *buf)
{
if(read(device, &buf, numbytes) != numbytes)
{
printf("Error occurred during buffer SPI read\n");
return -1;
}
return 0;
}

//*************************************************
//* LCD FUNCTIONS *
//*************************************************
/*NOTE: DO NOT directly include libBBB.h for LCD functions!
* Instead include libLCD.h as this implements the
* screen control and full initialization.
*/
int initLCD()
{
//initialize the pins
initPin(RS);
initPin(E);
initPin(D4);
initPin(D5);
initPin(D6);
initPin(D7);

//set direction
setPinDirection(RS,OUT);
setPinDirection(E,OUT);
setPinDirection(D4,OUT);
setPinDirection(D5,OUT);
setPinDirection(D6,OUT);
setPinDirection(D7,OUT);

setPinValue(E,OFF);

//initialize the screen
pauseNanoSec(1500000);
initCMD(0x30);
pauseNanoSec(5000000);
initCMD(0x30);
pauseNanoSec(5000000);
initCMD(0x30);
pauseNanoSec(5000000);
initCMD(0x20);

pauseNanoSec(5000000);
writeCMD(0x2C);
pauseNanoSec(5000000);
writeCMD(0x08);
pauseNanoSec(5000000);
writeCMD(0x01);
pauseNanoSec(2000000);
writeCMD(0x06);
pauseNanoSec(5000000);
writeCMD(0x0E);
pauseNanoSec(5000000);

return 0;
}

void initCMD(unsigned char cmd)
{
//bring rs low for command
setPinValue(RS,OFF);
pauseNanoSec(500000);

//send the highest nibble only
setPinValue(E,ON);
setPinValue(D7,((cmd >> 7) & 1));
setPinValue(D6,((cmd >> 6) & 1));
setPinValue(D5,((cmd >> 5) & 1));
setPinValue(D4,((cmd >> 4) & 1));
pauseNanoSec(500000);
setPinValue(E,OFF);
pauseNanoSec(500000);
}

int writeChar(unsigned char data)
{
//bring rs high for character
pauseNanoSec(500000);
setPinValue(RS,ON);
pauseNanoSec(500000);

//send highest nibble first
setPinValue(E,ON);
setPinValue(D7, ((data >> 7) & 1));
setPinValue(D6, ((data >> 6) & 1));
setPinValue(D5, ((data >> 5) & 1));
setPinValue(D4, ((data >> 4) & 1));
pauseNanoSec(500000);
setPinValue(E,OFF);
pauseNanoSec(500000);

//send the low nibble
setPinValue(E,ON);
setPinValue(D7, ((data >> 3) & 1));
setPinValue(D6, ((data >> 2) & 1));
setPinValue(D5, ((data >> 1) & 1));
setPinValue(D4, (data & 1));
pauseNanoSec(500000);
setPinValue(E,OFF);
pauseNanoSec(500000);

return 0;
}

int writeCMD(unsigned char cmd)
{
//bring rs low for command
setPinValue(RS, OFF);
pauseNanoSec(500000);

//send highest nibble first
setPinValue(E,ON);
setPinValue(D7, ((cmd >> 7) & 1));
setPinValue(D6, ((cmd >> 6) & 1));
setPinValue(D5, ((cmd >> 5) & 1));
setPinValue(D4, ((cmd >> 4) & 1));
pauseNanoSec(500000);
setPinValue(E,OFF);
pauseNanoSec(500000);

//send the low nibble
setPinValue(E,ON);
setPinValue(D7, ((cmd >> 3) & 1));
setPinValue(D6, ((cmd >> 2) & 1));
setPinValue(D5, ((cmd >> 1) & 1));
setPinValue(D4, (cmd & 1));
pauseNanoSec(500000);
setPinValue(E, OFF);
pauseNanoSec(500000);

return 0;
}

//*************************************************
//* ADC FUNCTIONS *
//*************************************************
int initADC(int mgrnum)
{
FILE *ain;
char buf[5];
char buf2[50] = "/sys/devices/bone_capemgr.";

//build path to setup ain
sprintf(buf,"%i",mgrnum);
strcat(buf2,strcat(buf,"/slots"));

ain = fopen(buf2, "w");
if(ain == NULL) printf("Analog failed load\n");
fseek(ain,0,SEEK_SET);
fprintf(ain,"cape-bone-iio");
fflush(ain);
fclose(ain);

return 0;
}

int readADC(int helpnum, char* ach)
{
FILE *aval;
int value;
char buf[5];
char buf2[50] = "/sys/devices/ocp.2/helper.";

//build file path to read adc
sprintf(buf,"%i",helpnum);
strcat(buf2,strcat(buf,ach));

aval = fopen(buf2, "r");
if(aval == NULL) printf("Analog failed to open\n");
fseek(aval,0,SEEK_SET);
fscanf(aval,"%d",&value);
fflush(aval);
fclose(aval);

return value;
}

//********************************************
//* TIME FUNCTIONS *
//********************************************
void pauseSec(int sec)
{
time_t now,later;

now = time(NULL);
later = time(NULL);

while((later – now) < (double)sec)
later = time(NULL);
}

int pauseNanoSec(long nano)
{
struct timespec tmr1,tmr2;

//assume you are not trying to pause more than 1s
tmr1.tv_sec = 0;
tmr1.tv_nsec = nano;

if(nanosleep(&tmr1, &tmr2) < 0)
{
printf("Nano second pause failed\n");
return -1;
}
return 0;
}

[/sourcecode]

LibBBB.h

[sourcecode language=”c”]
#ifndef _libBBB_H_
#define _libBBB_H_

//Includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>

//Type definitions
typedef struct {
struct termios u;
}UART;

//Definitions
#define OUT "out"
#define IN "in"
#define ON 1
#define OFF 0

#define USR1 "usr1"
#define USR2 "usr2"
#define USR3 "usr3"
#define P8_13 "P8_13"
#define E 65
#define RS 27
#define D4 46
#define D5 47
#define D6 26
#define D7 44
#define AIN0 "/AIN0"
#define AIN1 "/AIN1"
#define AIN2 "/AIN2"
#define AIN3 "/AIN3"
#define AIN4 "/AIN4"
#define AIN5 "/AIN5"
#define AIN6 "/AIN6"
#define AIN7 "/AIN7"

//Device Tree Overlay
int addOverlay(char *dtb, char *overname);

//USR Prototypes
int setUsrLedValue(char* led, int value);

//GPIO Prototypes
int initPin(int pinnum);
int setPinDirection(int pinnum, char* dir);
int setPinValue(int pinnum, int value);
int getPinValue(int pinnum);

//PWM Prototypes
int initPWM(int mgrnum, char* pin);
int setPWMPeriod(int helpnum, char* pin, int period);
int setPWMDuty(int helpnum, char* pin, int duty);
int setPWMOnOff(int helpnum, char* pin, int run);

//UART Prototypes
int initUART(int mgrnum, char* uartnum);
void closeUART(int fd);
int configUART(UART u, int property, char* value);
int txUART(int uart, unsigned char data);
unsigned char rxUART(int uart);
int strUART(int uart, char* buf);

//I2C Prototypes
int initI2C(int modnum, int addr);
void closeI2C(int device);
int writeByteI2C(int device, unsigned char *data);
int writeBufferI2C(int device, unsigned char *buf, int len);
int readByteI2C(int device, unsigned char *data);
int readBufferI2C(int device, int numbytes, unsigned char *buf);

//SPI Prototypes
int initSPI(int modnum);
void closeSPI(int device);
int writeByteSPI(int device,unsigned char *data);
int writeBufferSPI(int device, unsigned char *buf, int len);
int readByteSPI(int device, unsigned char *data);
int readBufferSPI(int device, int numbytes, unsigned char *buf);

//LCD 4-bit Prototypes
int initLCD();
int writeChar(unsigned char data);
int writeCMD(unsigned char cmd);
int writeString(char* str, int len);
int LCD_ClearScreen();
int LCD_Home();
int LCD_CR();
int LCD_Backspace();
int LCD_Move(int location);

//ADC Prototypes
int initADC(int mgrnum);
int readADC(int helpnum, char* ach);

//Time Prototypes
void pauseSec(int sec);
int pauseNanoSec(long nano);

#endif
[/sourcecode]

Após a execução de ambos códigos, os valores lidos na entrada analógico será exibido pelo próprio terminal.

Conclusão:

Apesar de apresentar um código e circuito eletrônico simples, o tutorial buscou apresentar a ferramenta conversor analógico-digital fornecida pela BeagleBone Black que pode ser utilizada em diversos projetos. Os procedimentos de compilação e execução descritos são os mesmos para qualquer projeto que se pretenda executar na BBB, inclusive, independente do Sistema Operacional que esteja instalado na BBB.

Referencias:

[1] http://www.thebrokendesk.com/post/reading-analog-values-and-efficacy-of-the-beaglebone-blacks-adc/
[2] http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/installation-on-ubuntu
[3] http://beaglebone.cameon.net/home/reading-the-analog-inputs-adc

Summary
Review Date
Reviewed Item
Beaglebone Black
Author Rating
51star1star1star1star1star

One Response to “Tutorial – BeagleBone Black: Conversão Analógico-Digital”

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *