Cov txheej txheem:
- Kauj ruam 1: Tsim Sine Data Array
- Kauj Ruam 2: Pab kom Parallel Output
- Kauj ruam 3: Pab kom cuam tshuam
- Kauj Ruam 4: R/2R DAC
- Kauj ruam 5: Tag Nrho Cov Cai
Video: 3 Theem Sine Wave Generator Raws Li Arduino Due: 5 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
lub hom phiaj ntawm qhov qhia tawm no yog txhawm rau pab ib tus neeg uas tau sim siv vim qhov ua tau zoo dua qub + tsis muaj kev siv + tsis muaj cov ntaub ntawv pab tau.
txoj haujlwm no muaj peev xwm tsim tau txog 3 theem sine wave @ 256 qauv / voj voog ntawm qhov qis qis (<1kHz) thiab 16 qhov piv txwv / voj voog @ siab ntau zaus (txog 20kHz), uas yog qhov zoo txaus los ua kom yooj yim los ntawm LPFs yooj yim thiab cov zis yuav luag zoo tag nrho.
cov ntawv txuas tsis yog kuv qhov kawg rau kuv ntxiv qee qhov tshwj xeeb ntxiv tab sis cov tub ntxhais zoo ib yam rau qhov ntawd. Nco tseg cov qauv/voj voog tau teeb tsa qis dua nqe lus saum toj no.
txij li CPU lub peev xwm tau txais txiaj ntsig zoo tshaj plaws los ntawm txoj hauv kev uas tau qhia hauv cov ntawv txuas, Kuv tau siv Arduino Uno los ua kev tswj hwm, uas siv Arduino Due qhov cuam tshuam sab nraud kom dhau zaus zaus rau Arduino Due. Ntxiv rau kev tswj hwm zaus, Arduino Uno tseem tswj hwm qhov dav (los ntawm cov peev txheej digital-meter + OpAmp) ntxiv rau I/O --- yuav muaj ntau chav ua si nrog.
Kauj ruam 1: Tsim Sine Data Array
Txij li kev suav lub sijhawm tiag tiag yog CPU xav tau, sine cov ntaub ntawv array xav tau rau kev ua haujlwm tau zoo dua
uint32_t sin768 PROGMEM =…. thaum x = [0: 5375]; y = 127+127*(kev txhaum (2*pi/5376/*lossis qee qhov # koj nyiam nyob ntawm qhov xav tau*/))
Kauj Ruam 2: Pab kom Parallel Output
Tsis zoo li Uno, Due muaj qhov txwv siv. Txawm li cas los txhawm rau tsim 3 theem sine yoj raws Arduino Uno, 1st ntawm txhua qhov, kev ua tau zoo tsis txaus siab vim nws qhov MCLK qis (16MHz thaum Dua yog 84MHz), thib ob, nws txwv GPIO tuaj yeem tsim tawm 2 theem tso tawm thiab koj xav tau ntxiv analog Circuit Court los tsim theem 3 (C = -AB).
Ua raws GPIO kev ua tau zoo feem ntau yog ua los ntawm kev sim thiab sim+tsis muaj txiaj ntsig ntawm SAM3X
PIOC-> PIO_PER = 0xFFFFFFFE; // PIO controller PIO Enable register (xa mus rau p656 ntawm ATMEL SAM3X cov ntawv) thiab https://arduino.cc/en/Hacking/PinMappingSAM3X, Arduino Due pin 33-41 thiab 44-51 tau qhib
PIOC-> PIO_OER = 0xFFFFFFFE; // PIO cov tswj kev tso tawm kom tso npe, xa mus rau p657 ntawm ATMEL SAM3X cov ntawv PIOC-> PIO_OSR = 0xFFFFFFFE; // PIO maub los tso zis xwm txheej sau npe, xa mus rau p658 ntawm ATMEL SAM3X cov ntawv teev npe
PIOC-> PIO_OWER = 0xFFFFFFFE; // PIO cov ntawv tso tawm kom tso npe, xa mus rau p670 ntawm ATMEL SAM3X cov ntawv teev npe
// PIOA-> PIO_PDR = 0x30000000; // xaiv tau raws li kev pov hwm, tsis zoo li cuam tshuam rau kev ua haujlwm, tus lej pin 10 txuas rau ob lub PC29 thiab PA28, tus lej digital 4 txuas rau ob lub PC29 thiab PA28, ntawm no txhawm rau cuam tshuam PIOA #28 & 29
Kauj ruam 3: Pab kom cuam tshuam
Txhawm rau ua kom nws qhov ua tau zoo tshaj plaws, CPU load yuav tsum qis li sai tau. Txawm li cas los xij vim qhov tsis yog-1to1 kev sib tham ntawm CPU tus pin thiab Daws tus pin, yuav tsum tau ua haujlwm me ntsis.
Koj tuaj yeem txuas ntxiv ua kom zoo dua cov txheej txheem tab sis chav muaj tsawg heev.
tsis muaj dab tsi TC7_Handler (tsis muaj dab tsi) {TC_GetStatus (TC2, 1);
t = t%cov qauv; // siv t%piv txwv es tsis txhob 'yog' kom tsis txhob txeej ntawm t
phaseAInc = (preset*t)%5376; // siv %5376 kom tsis txhob muaj cov lej ntsuas ntau dhau
phaseBInc = (phaseAInc+1792)%5376;
phaseCInc = (phaseAInc+3584)%5376;
p_A = sin768 [phaseAInc] << 1; // xa mus rau PIOC: PC1 rau PC8, sib xws Arduino Due pin: tus pin 33-40, yog li ua haujlwm sab laug rau 1 tus lej
p_B = sin768 [phaseBInc] << 12; // xa mus rau PIOC: PC12 rau PC19, sib xws Arduino Due pin: tus pin 51-44, yog li ua haujlwm sab laug 12 tus lej
p_C = sin768 [phaseCInc]; // theem C tso tawm ua haujlwm PIOC: PC21, PC22, PC23, PC24, PC25, PC26, PC28 thiab PC29, sib xws Arduino Due pin: digital pin: 9, 8, 7, 6, 5, 4, 3, 10, feem
p_C2 = (p_C & B11000000) << 22; // qhov no tsim PC28 thiab PC29
p_C3 = (p_C & B00111111) << 21; // qhov no tsim PC21-PC26
p_C = p_C2 | p_C3; // qhov no tsim cov khoom sib luag ntawm theem C.
p_A = p_A | p_B | p_C; // 32 ntsis tso tawm = theem A (8 ntsis) | theem B | theem C
PIOC-> PIO_ODSR = p_A; // tso tawm tso tawm = p_A
t ++; }
Kauj Ruam 4: R/2R DAC
tsim 3x8bit R/2R DAC, thauj khoom ntawm google.
Kauj ruam 5: Tag Nrho Cov Cai
#define _BV (x) (1 << (x)); uint32_t sin768 PROGMEM = /* x = [0: 5375]; y = 127+127*(txhaum (2*pi/5376))*/
uint32_t p_A, p_B, p_C, p_C2, p_C3; // theem A theem B theem C tus nqi-txawm hais tias tso tawm yog 8bits nkaus xwb, p_A thiab p_B tus nqi yuav ua haujlwm los tsim qhov tshiab 32 ntsis tus nqi txhawm rau ua haujlwm nrog 32bit PIOC cov zis
uint16_t phaseAInc, phaseBInc, phaseCInc, freq, freqNew; uint32_t ncua; uint16_t kuaj, preset; uint32_t t = 0;
void teeb tsa () {
// qhov tso tawm ua ke PIOC teeb: Arduino Due pin33-40 tau ua haujlwm raws theem A tso tawm thaum tus pin 44-51 ua haujlwm rau theem B tso tawm
PIOC-> PIO_PER = 0xFFFFFFFE; // PIO controller PIO Enable register (xa mus rau p656 ntawm ATMEL SAM3X cov ntawv) thiab https://arduino.cc/en/Hacking/PinMappingSAM3X, Arduino Due pin 33-41 thiab 44-51 tau qhib
PIOC-> PIO_OER = 0xFFFFFFFE; // PIO cov tswj kev tso tawm kom tso npe, xa mus rau p657 ntawm ATMEL SAM3X cov ntawv teev npe
PIOC-> PIO_OSR = 0xFFFFFFFE; // PIO maub los tso zis xwm txheej sau npe, xa mus rau p658 ntawm ATMEL SAM3X cov ntawv teev npe
PIOC-> PIO_OWER = 0xFFFFFFFE; // PIO cov ntawv tso tawm kom tso npe, xa mus rau p670 ntawm ATMEL SAM3X cov ntawv teev npe
// PIOA-> PIO_PDR = 0x30000000; // xaiv tau raws li kev pov hwm, tsis zoo li cuam tshuam rau kev ua haujlwm, tus lej pin 10 txuas rau ob lub PC29 thiab PA28, tus lej digital 4 txuas rau ob lub PC29 thiab PA28, ntawm no txhawm rau cuam tshuam PIOA #28 & 29 // teeb tsa timer, xa mus rau https://arduino.cc/en/Hacking/PinMappingSAM3X, pmc_set_writeprotect (tsis tseeb); // lov tes taw sau kev tiv thaiv ntawm Kev Tswj Xyuas Lub Hwj Huam Sau npe
pmc_enable_periph_clk (ID_TC7); // pab kom lub moos peripheral lub sijhawm ntsuas 7
TC_Configure (/ * moos */TC2,/ * channel */1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1); // TC moos 42MHz (moos, channel, sib piv hom teeb tsa) TC_SetRC (TC2, 1, ntu); TC_Start (TC2, 1);
// pab kom ncua sij hawm cuam tshuam ntawm timer TC2-> TC_CHANNEL [1]. TC_IER = TC_IER_CPCS; // IER = cuam tshuam pab tso npe TC2-> TC_CHANNEL [1]. TC_IDR = ~ TC_IER_CPCS; // IDR = cuam tshuam cuam tshuam rau npe
NVIC_EnableIRQ (TC7_IRQn); // Pab kom muaj kev cuam tshuam nyob rau hauv cov duab vector cuam tshuam kev tswj hwm freq = 60; // initialize zaus li 60Hz preset = 21; // array index nce los ntawm 21 qauv = 256; // tso tawm cov qauv 256/lub voj voog luv = 42000000/((freq*kuaj)); // cuam tshuam suav TC_SetRC (TC2, 1, ntu); // pib TC Serial.begin (9600); // rau lub hom phiaj xeem}
void checkFreq ()
{freqNew = 20000;
if (freq == freqNew) {} lwm
{freq = freqNew;
yog (freq> 20000) {freq = 20000; /*max zaus 20kHz*/};
yog (freq <1) {freq = 1; /*min zaus 1Hz*/};
yog (freq> 999) {preset = 384; piv txwv = 14;} // rau zaus> = 1kHz, 14 qhov piv txwv rau txhua lub voj voog
lwm yog (freq> 499) {preset = 84; piv txwv = 64;} // rau 500 <= zaus 99) {preset = 42; kuaj = 128;} // rau 100Hz <= zaus <500Hz, 128 cov qauv/voj voog
lwm {preset = 21; piv txwv = 256;}; // rau zaus <100hz, 256 kuaj rau txhua lub voj voog
luv = 42000000/(freq*kuaj); t = 0; TC_SetRC (TC2, 1, luv); }}
void voj () {
checkFreq (); ncua (100); }
tsis muaj dab tsi TC7_Handler (tsis muaj dab tsi)
{TC_GetStatus (TC2, 1);
t = t%cov qauv; // siv t%piv txwv kom zam dhau ntawm t phaseAInc = (preset*t)%5376; // siv %5376 kom tsis txhob muaj cov lej ntsuas ntau dhau
phaseBInc = (phaseAInc+1792)%5376;
phaseCInc = (phaseAInc+3584)%5376;
p_A = sin768 [phaseAInc] << 1; // xa mus rau PIOC: PC1 rau PC8, sib xws Arduino Due pin: tus pin 33-40, yog li ua haujlwm sab laug rau 1 tus lej
p_B = sin768 [phaseBInc] << 12; // xa mus rau PIOC: PC12 rau PC19, sib xws Arduino Due pin: tus pin 51-44, yog li ua haujlwm sab laug 12 tus lej
p_C = sin768 [phaseCInc]; // theem C tso tawm ua haujlwm PIOC: PC21, PC22, PC23, PC24, PC25, PC26, PC28 thiab PC29, sib xws Arduino Due pin: digital pin: 9, 8, 7, 6, 5, 4, 3, 10, feem
p_C2 = (p_C & B11000000) << 22; // qhov no tsim PC28 thiab PC29
p_C3 = (p_C & B00111111) << 21; // qhov no tsim PC21-PC26 //Serial.println(p_C3, BIN); p_C = p_C2 | p_C3; // qhov no tsim cov khoom sib luag ntawm theem C.
p_A = p_A | p_B | p_C; // 32 ntsis tso tawm = theem A (8 ntsis) | theem B | theem C //Serial.println(p_A>>21, BIN); // PIOC-> PIO_ODSR = 0x37E00000;
PIOC-> PIO_ODSR = p_A; // tso npe tso tawm = p_A t ++; }
Pom zoo:
Miniaturizing Arduino Autonomous Robot (Av Rover / Tsheb) Theem 1 Qauv 3: 6 Cov Kauj Ruam
Miniaturizing Arduino Autonomous Robot (Land Rover / Car) Stage1Model3: Kuv txiav txim siab los miniaturize Land Rover / Tsheb / Bot kom txo qhov loj thiab siv hluav taws xob ntawm txoj haujlwm
Arduino Raws li ISP -- Hlawv Hex Cov Ntaub Ntawv hauv AVR -- Fuse hauv AVR -- Arduino Raws li Programmer: 10 Kauj Ruam
Arduino Raws li ISP || Hlawv Hex Cov Ntaub Ntawv hauv AVR || Fuse hauv AVR || Arduino As Programmer: ……………………… Please SUBSCRIBE To my YouTube channel for more videos …….. Kab lus no yog txhua yam hais txog arduino li isp. Yog tias koj xav xa cov ntawv hex lossis yog tias koj xav teeb tsa koj lub fuse hauv AVR ces koj tsis tas yuav yuav tus programmer, koj tuaj yeem ua
Ntau lawm ntawm Sine Wave Tswj Pawg Thawj Coj: 5 Cov Kauj Ruam
Kev tsim tawm ntawm Sine Wave Control Board: Lub sijhawm no nws yog ib theem-sine yoj tawm ntawm daim phiaj tswj hwm, ua raws los ntawm ib-theem sine wave tawm-daim phiaj tswj hwm pawg thawj coj, tom qab ntawd peb-theem sine wave tawm-daim phiaj tswj hwm, thiab thaum kawg yog peb-theem sine yoj tawm ntawm daim phiaj tswj hwm. Peb cia siab tias
Huab Cua Raws Li Lub Tshuab Hluav Taws Xob (ESP8266 Raws Li Midi Generator): 4 Cov Kauj Ruam (nrog Duab)
Huab Cua Raws Li Lub Tshuab Hluav Taws Xob (ESP8266 Raws Li Midi Generator): Nyob zoo, hnub no kuv yuav piav qhia yuav ua li cas thiaj ua rau koj tus kheej me ntsis Huab cua raws li lub tshuab hluav taws xob. thiab lub teeb pom kev zoo.Tsis txhob cia siab tias nws yuav ua txhua zaj nkauj lossis chord progr
Kev Nkag Mus Rau Cov Hauv Paus Cov Hauv Paus Cov Ntaub Ntawv Siv DB410 Raws Li Ethernet Dongle: 6 Cov Kauj Ruam
Kev Nkag Mus Rau Cov Hauv Paus Cov Hauv Paus Cov Ntaub Ntawv Siv DB410 Raws Li Ethernet Dongle: Lub Hom Phiaj: Txhim kho cov cuab yeej cuab tam thiab rov ua dua cov ntsiav kom ntxig USB Ethernet CDC Gadget txhawb nqa; Rov tsim boot.img los ntawm Linaro rau khau raj USB Ethernet CDC; Tsim NFS server los tuav lub hauv paus cov ntaub ntawv system; IP teeb tsa hauv DEVICE thiab HOST