Wednesday 11 October 2017

Moving Media Pic18f


Divertirsi con HC08 Ecco un bel po 'di progetto per un fine settimana di pioggia, tutto questo può essere realizzato nel corso di un week-end e per meno di USD 15. Questa pagina è passato attraverso varie riscritture, soprattutto per sbarazzarsi della mia scrittura modalità sproloquio, ma sembra ho solo bisogno di scrivere fuori di me stesso. Sentitevi liberi di saltare la prima parte. Per scopi di riferimenti e convenienza Ive mettere tutti i link utili qui in alto della pagina: Sommario Anche se questa è una pagina piuttosto lungo che ha un tipo di storia lineare e Ive significava che per essere letto direttamente attraverso. Detto questo mi rendo conto che un contenuto della tabella è a portata di mano, soprattutto se in seguito si desidera tornare indietro e cercare qualcosa. Inoltre permette di saltare la parte sproloquio e scendere al compito di ottone, a partire costruire l'hardware. Introduzione Questa pagina è su come iniziare con divertirsi con microcontrollori, in particolare con la famiglia Freescale MC68HC908 di controllori. Questa pagina è rivolto a principianti in microcontrollori. Mentre un progetto microcontrollore può non essere adatto come primo progetto in elettronica spero di dimostrare che non è così difficile sia. Il controller qui può essere messo insieme e l'ambiente di sviluppo creato in pochi sera e per meno di 15 dollari, se avete le infrastrutture di base, un personal computer e strumenti, al suo posto. Un sacco di persone sono interessate a microcontrollori, come testimoniato dal numero infinito di pagine per hobby in rete. Se siete nuovi a questo hobby che potrebbe avere senso per mettere in pausa per un momento e pensare perché si vuole essere coinvolto. La motivazione mi preoccupa sempre molto, in più di un senso della parola. Mentre Im non sempre disponibile con le mie motivazioni, almeno cerco di essere onesto con me stesso. Un sacco di gente vagamente citare che vogliono imparare a fare microcontrollori o imparare un nuovo linguaggio di programmazione. Queste sono come buone ragioni qualsiasi, ma ho il sospetto che dietro queste affermazioni ci sono sogni o ambizioni che mirano ulteriormente. Cerca dentro di te e scoprire che cosa ti fa spuntare. Quindi, prima di arrivare alla sostanza tecnica attuale, mi permetta di fare qualche ricerca di anima qui con te, forse provocherà alcuni pensieri che vi aiuteranno a rendere la vostra mente. Perché microcontrollori Ho trascorso circa due ore ogni giorno pendolarismo e non prima di Ive ha iniziato la macchina miei pensieri cominciano a chiedersi e mi vengono queste idee. Hey, sarebbe bello per monitorare i consumi elettrici della casa, basta misurare il treno di impulsi sul contatore, o il modo di creare che rooter CNC Ive ha sempre sognato e ho potuto costruire un forno ad induzione o come su un dispositivo di levitazione. Ciò che è comune a queste chimere è che la maggior parte di questi sarebbe meglio implementato con un microcontrollore. Un microcontrollore è un mini computer sorta con una unità centrale di elaborazione o CPU, della memoria e delle periferiche o dispositivi di uscita di ingresso. Lascia la faccia esso, i circuiti analogici e chip di logica non sono solo la strada da percorrere oggi. Un microcontrollore può creare impulsi e le frequenze, i segnali di misura, fare matematica, fare la logica e controllarli in modo straordinariamente preciso e ripetibile. Non ci sono le tolleranze di cui preoccuparsi, non taglio di fare, senza bisogno di dispositivi di misura speciali. Tutto sta andando digitale e questo è il modo in cui dovrebbe essere. Ovviamente, è naturale. Tutto ciò che si può fare meglio che posso fare è l'atteggiamento di elaborazione digitale verso circuiti analogici. Ritenendo lungo termine Im un programmatore professionista coinvolto nella progettazione di sistemi embedded su base giornaliera per il passato un quarto di secolo, lunga quasi quanto theyve esisteva. Mi piace anche armeggiare con queste cose nel mio tempo libero. Ora, come contorto è che con questo insieme di mente schizofrenica non posso fare a portare un po 'del mio bagaglio professionale alle mie attività per il tempo libero, anche se le motivazioni, gli obiettivi, i requisiti e le risorse di professionisti e hobbisti differiscono notevolmente. Imparare cose nuove, come microcontrollori, è divertente, ma è anche un investimento. Un investimento in voi stessi e il vostro futuro. Come ogni investimento che richiede spendere una cosa per guadagnare un'altra. Tempo e denaro. Il denaro è una considerazione secondaria chiunque può essere ricco, ma nessuno vive per sempre in modo che tutti noi dobbiamo considerare attentamente ciò che facciamo con il nostro tempo. Come per qualsiasi investimento, è naturale aspettarsi da esso qualcosa in cambio, sia esso in forma di competenze, opportunità, gratificazione o il divertimento semplicemente pura. Allora, cosa ha tutto questo ha a che fare con microcontrollori Imparare a fare microcontrollori è un grande investimento in termini di spesa prezioso tempo libero. Nessuno vuole vedere il loro investement andare busto quindi vale la pena di investire con attenzione. Le preoccupazioni sono, che cosa se il chip Im usando viene interrotta, cosa succede se gli strumenti Im usando ottenere interrotto, Sto per essere lasciato in una nicchia in cui gli altri utenti sono pochi e lontani tra loro. Questo può sembrare un po 'pomposo, di parlare così, nel contesto di un progetto hobby, ma come si vive si impara, e Ive visto così tante una tantum progetti temporanei, sia hardware ma soprattutto il software, a vivere ben oltre le più selvagge aspettative dei loro creatori. scommessa Ill tutto ciò che i ragazzi che scrivono il codice di Unix più di quaranta anni fa, non avevano idea che un sacco di questo codice dovrebbe essere ancora in esecuzione e tooted come il sistema operativo più avanzato oggi disponibile: Mac OS X Ive ha trovato a giocare con i microcontrollori sia gratificante e divertimento, e ha anche pagato il mio ipotecario, ma sicuramente anche ha ingoiato una grossa fetta della mia vita. Ok, così lascia vedere dove questo tipo di pensiero mi ha portato e perché. Im non mettendo questo in avanti come l'unico modo giusto di andare su di esso, Im solo condividere il mio punto di vista. Correzioni e revisioni di mie opinioni sono incoraggiati. Se siete ancora leggendo, ricordare, che a volte paga per ascoltare gli altri whove stato-ci-fatto-che, ma si dovrebbe anche studiare se stessi e scoprire che cosa è che si vuole veramente fare. E 'il progetto e la vostra vita. Alla ricerca di un microcontrollore Per anni Ive stato alla ricerca di un microcontrollore adatto che adempiere ai miei vincoli autoimposti. In passato, io ei miei amici hanno avuto grandi cose divertenti costruzione della 68HC11 famiglia di dispositivi, ma, anche se un bel dispositivo, lascia a desiderare rispetto alle offerte più moderni con flash interna e quant'altro. Ecco le mie esigenze di listino per un microcontrollore: Minimal adattatore di programmazione in-chip singolo pacchetto DIL USB parti esterne minime C-programmabili Strumenti gratuiti Semplice, ElegantInterestingly, questa lista è sempre quasi lo stesso indipendentemente da quello che sto contemplando a che fare con esso, più o meno come la mia cucina davvero di prima prendo mezzo chilo di burro, ciotola di zucchero, mezzo litro di panna. una mezza dozzina di uova e poi inizio a pensare cosa cucinare e mangiare in seguito, Ill discutere questi per dare un principiante un punto di vista sulla questione. Si prega di notare che ci sono molti punti di vista su questo, nessuno, compreso il mio, di cui necessariamente assolutamente corretto. Nel seguente Ill discutere mie opinioni su ciascuno dei requisiti sopra elencati per una certa lunghezza. C-programmabili La programmazione è al centro di microcontrollori - è ciò che li rende così, ed è ciò che li rende così universalmente applicabile alle varie attività. Quelle persone alla fonderia di silicio che sfornare questi chip per noi non so o importa quello che facciamo con loro. E non hanno a, che è la bellezza di esso, perché noi, come i programmatori messo nell'anima, il programma, che determina ciò che fa. Quindi le parti possono essere fabbricate in milioni, portando il costo basso. Ma quei chip maledettamente solo comprendere e osservare livelli di tensione nelle loro celle di memoria e mentre a volte è necessario e stranamente soddisfacente specificando quelle tensioni con uno e zero, sicuramente non è la strada da percorrere su una scala più ampia. Quindi abbiamo bisogno di qualcosa di più alto livello che ci permette di pensare in termini più astratti di flop logiche e flip booleani, che sono gli elementi costitutivi di microcontrollori. Abbiamo bisogno di un linguaggio di programmazione. Ora c'è qualcosa di linguaggi di programmazione che rende la schiuma persone in bocca. Non so cosa sia, ma c'è sicuramente qualcosa di interessante su di loro e tutti sembrano avere opinioni molto precise su di loro. Anche a me. Un sacco di l'argomentazione e la discussione sui linguaggi di programmazione sembrano centro attorno caratteristiche tecniche o problemi filosofici sul perché un linguaggio di programmazione è migliore di un altro. Mentre ci sono certamente differenze e si può proporre argomenti fondati per vari aspetti di diverse lingue, trovo che questa discussione sorta è centrata intorno le domande sbagliate. La questione non è su quale linguaggio di programmazione è il migliore, ma piuttosto che uno si dovrebbe usare, e quindi imparare. Tutti i linguaggi di programmazione sono praticamente la stessa. Come potevano essere diversi, visto che l'architettura computing è sempre più o meno lo stesso vecchio Von Neumann ei problemi sono sempre gli stessi, flusso di controllo, la rappresentazione dei dati, il calcolo e la gestione dello storage. Prendere una decisione su quelli, gettare in una sintassi e, oplà, abbiamo un linguaggio di programmazione Naturalmente, ci sono alcune differenze e alcune lingue sono migliori di altri, ma le difficoltà essenziali di programmazione non sono suscettibili di essere risolti con una programmazione lingua, qualsiasi linguaggio di programmazione, in qualunque momento presto se potessero essere, sono sicuro che sarebbe stato risolto già - basta guardare i linguaggi di programmazione 2000 a Wikipedia. Così come si fa a scegliere un linguaggio di programmazione Per me la scelta è ovvia: si seleziona la ragazza più popolare in città. So che la vecchia barzelletta su mosche e Pat mucca, ma quando qualcosa è popolare non ha ottenuto di essere qualcosa di buono su di esso. E non vi è sicurezza nei numeri, mi porta al mio animaletto vista tema a lungo termine. Quando c'è una grande base di utenti si ottiene: più strumenti più persone a chiedere aiuto codice più di codice più libero migliore documentazione idiosynchracies meglio compreso meno errori e bug negli strumenti e il linguaggio strumenti più stabili maggiori opportunità di lavoro a futureAs spesso nella vita, vale la pena di prendere la via di mezzo. Sì, si tratta di un circolo vizioso che lega di progettare decenni decisioni fatte fa, ma non può sfuggire il passato se si ha il futuro in mente. Ora è neanche che ironico e il fortunato vincitore è C C non è mai stato il mio linguaggio di programmazione preferito ancora sia professionalmente e hobby-saggio che è l'unica scelta mi viene in mente quando si parla di piccoli microcontrollori. Gli strumenti e il linguaggio sono maturi e standardizzato, anche lo standard C99 è di dieci anni il prossimo anno. Ma hey, un sacco di gente l'uso di base o di un linguaggio simile al C migliorato per programmare microcontrollori, che sicuramente ha un senso BASIC ha un posto speciale nel mio cuore, era la prima lingua che ho imparato e ha ancora certo fascino nella sua semplicità e facilità di imparare. Tuttavia, non avrei mai considerare l'utilizzo per qualcosa di reale. Beh, questo non è del tutto vero solo qualche settimana fa ero bene sul mio modo di scrivere un compilatore BASIC per HC08, avevo il linker e l'assemblatore pronto, e il compilatore ticchettio, ma per fortuna sono venuto a miei sensi prima che ho sprecato più tempo su di esso. Parlando di BASIC, quello BASIC stiamo parlando ANSI BASIC, o qualche prodotto proprietario L'originale Dartmouth BASIC (nato a -64 come me) era un linguaggio molto semplice che conteneva tutti gli elementi di base che è necessario in un linguaggio di programmazione, ma mancavano le caratteristiche di astrazione di livello superiore di base che penso siano essenziali, come subroutine con nome, variabili locali e passaggio di parametri e istruzioni di controllo strutturali, senza le quali la programmazione è piuttosto simile alla programmazione assembler, il che rende difficile gestire qualsiasi cosa complessa con successo. Naturalmente, più tardi varianti di BASIC aggiunto queste caratteristiche, solo così tanti di loro è andato a modo loro, in modo che siano tutti uguali, solo diverse Con C le persone che possono (), il linguaggio e gli strumenti saranno qui tra vent'anni quando io o o qualcun altro ha bisogno di tornare e modificare il software. Immaginate di ricevere un vecchio programma BASIC per giocare a palla con dieci anni di tempo. E questa necessità di modificare non è un caso, è un quando si parla di prodotti di proprietà rispetto a linguaggi standard: mentre si può imparare a programmare in poche settimane e imparare una nuova lingua, qualsiasi lingua, in giorni, ci vogliono anni per padroneggiare e imparare i minimi dettagli sullo dove si nascondono i mali, così a me non ha senso investire in imparare qualcosa che non può esistere domani. Le aziende vanno e vengono, vengono comprati, venduti e uniti, prodotti fuori produzione e uccisi. Quindi, personalmente, non avrei mai investire di programmazione in un linguaggio che non ha un eccezionalmente elevata probabilità di sopravvivenza. Un esempio calzante, Microsofts Quick Basic per Mac è stato interrotto, l'uccisione di un prodotto di successo che mi è stato personalmente coinvolto in. Lo stesso è accaduto ad un amico sulla versione PC. Vado fino a fare la lingua e strumenti influenzare la scelta del chip. Se un chip non è supportato da GNU C è un punto negativo definito. Se cant essere programmato in C è un non avviamento. Nessun chip è così grande che ha senso investire su ri-imparare un nuovo linguaggio di programmazione quando la concorrenza è destinata a offrire qualcosa che può essere programmato con C. Prima di chiudere questa sezione piuttosto lungo e molto probabilmente noioso sui linguaggi di programmazione, Non posso fare a menzionare il progetto Arduino. Chiunque sia interessato a entrare in microcontrollori dovrebbe check it out. Anche se credo che l'idea di avere ancora un altro IDE e l'aggiunta di una sorta di preprocessore automatica sulla parte superiore C in realtà non ha senso per me, il progetto ha molto da offrire. pacchetto DIL In ambienti professionali, a montaggio superficiale dispositivi non sono solo un fatto di vita, ma una caratteristica desiderabile. Tuttavia, per l'hobbista sono un vero e proprio dolore nei quarti posteriori. Non solo è necessario un circuito stampato, quindi la saldatura loro è anche nessun pezzo di torta. Si può fare in un laboratorio di casa - Ive fatto io stesso, ma Ive stato anche costretto a esternalizzare una parte di saldatura SMD su una delle mie schede di hobby E non è sempre facile per i professionisti sia solo la settimana scorsa ho visto due tentativi falliti professionali saldare un package QFP a un prototipo. A sinistra ci sono due MC68HC908 chip con un SNT moneta da 20 e una resistenza di 14 W per riferimento dimensioni. La sinistra è un GZ16 in un package LQFP 32 pin e quella a destra è JB8 in un package PDIP 20 pin. Clicca sull'immagine per ingrandirla. È possibile saldare alcuni pacchetti SMD su un forno modificato o si può fare ciò che Ive fatto, che si saldare tutti i pin in una massa solida che Ive ha poi pulito con uno stoppino di saldatura. Ma la saldatura non è il problema più grande. Per me, il problema più grande è che è necessario un PCB. Ci vuole tempo per progettare e realizzare un PCB e per questo ha senso per incorporare tutti i circuiti della scheda, compresi quelli che si couldve appena Vero-imbarcati. Quindi, ci vuole anche di più, e prima di sapere che il vostro entusiasmo è andato e il progetto diventa solo uno di quelli finitura Ill un giorno - Progetti. Ecco un progetto che per il momento si è a corto di vapore, nascosto vergognosamente in un angolo lontano del mio disco rigido. Quello che voglio è qualcosa che può essere fatto fuori insieme nel giro di poche ore o pochi giorni su una scheda di prototipazione. È vero, ci sono schede di collegamento pronti per la maggior parte dei pacchetti SMD e uno di questi giorni Ill ottenere alcuni, e anche se il denaro non è la preoccupazione, di per sé, in un hobby, si va contro il grano di utilizzare 10 USD per montare un 2 USD Chip, e continua ad avere per breadboard tutto il resto. Così, uno dei requisiti fondamentali è imballaggio DIL. Supporto USB mi sembra di passare attraverso l'hardware del PC, il che significa per lo più computer portatili, ad un ritmo allarmante. Sia in privato e professionale. E venendo da circostanze non troppo ricchi mi duole vedere alla fine roba completamente funzionale fino a una discarica. Così io sogno di usarli per qualcosa. Questo usato per essere facile con porte parallele e comunicazione seriale, ma negli ultimi anni i computer, soprattutto portatili, spesso vengono senza altre porte di USB. Così i giorni di porte parallele e seriali sono numerate. Così che cosa questo ha a che fare con i microcontrollori Beh, tante delle mie idee sarebbe meglio attuata in modo che la roba in tempo reale di basso livello è fatto sul microcontrollore ma il resto, come networking, storage e l'interfaccia utente, su un computer corretta. Sì, Ho visto stazioni meteorologiche che vantano un server Web su un formato del PWB scatola di fiammiferi, ma per me con quel vecchio computer portatile in un angolo per registrare e controllare i miei parametri di turbine eoliche avrebbe molto più senso, tranne che cant fare qualsiasi roba in tempo reale con Windows su di esso e non posso collegare nulla ad esso perché non ha la porta seriale. Sicuramente si può aggiungere una porta USB - Serial e molte volte che è la risposta, ma che dire se la mia grande idea si trasforma in un prodotto di un giorno Una porta seriale USB grava il prodotto con 20 dollari per antipasti e comporta complessità e limita ancora la connettività a quello che una porta seriale in grado di offrire. È venuto a pensarci bene, basic stamp sarebbe riportarlo ancora di più. Così ritenendo lungo termine credo abbia senso per me di stringere i denti e imparare a fare USB. Chip singolo Come ho detto, Ive ha avuto grande divertimento con HC11, ma a meno che non si può stipare il codice in 512 byte è necessario utilizzare la memoria ROM esterna per la memorizzazione del programma. Si richiede anche a una circuiteria molto minima esterna ripristino e un oscillatore di clock o di un cristallo. Questa non è la tecnologia di oggi, voglio qualcosa che ha tutto in un unico chip. Non solo si è aiutare a mantenere bassi i costi, ma riduce anche la complessità. Nel circuito di programmazione Sono lontani i giorni in cui abbiamo cancellato EPROM con raggi UV e bruciato in un ballo-programmatore, e ciò che è buono. microcontrollori di oggi, soprattutto in un progetto hobby, dovrebbero essere programmabili in-circuit. E senza un costoso adattatore di programmazione in-circuit, troppo. Posso servire fuori 300 dollari per un kit di valutazione che include l'adattatore, ma non voglio preferisco qualcosa di semplice che può essere agganciato ad una porta seriale più o meno direttamente. O meglio ancora, dal momento che ho voluto avere in ogni caso USB, sarebbe ideale per programmare attraverso la connessione USB. Credo che questo è ancora una volta la visione a lungo termine: mentre posso spendere i soldi per attrezzi professionali, che cosa succede se i miei sforzi sono qualcosa che qualche altro hobbisti vuole provare troppo La loro situazione forse completamente differente, pensare a studenti e scuole per esempio. Oltre a farlo da zero solo è il mio modo di fare le cose Strumenti gratuiti lasciatemi dire che io non sono un sostenitore del software libero, ma allo stesso tempo vedo che c'è un sacco di senso in essa e alcuni di essi è in realtà maledettamente buono . Molti produttori di chip e produttori di strumenti forniscono versioni gratuite (come la birra gratis) dei loro strumenti e compilatori. Che è grande e fine, tanto più che alcuni di loro sono migliori, in alcune misure, che le loro parti libero (come la libertà) del contatore. Tuttavia, essi sono in esso per i soldi, il che significa che ci deve essere una cattura da qualche parte, come è possibile utilizzare solo 32 file e 1 codice kB per file e max 4 codice kB. Naturalmente, la pressione del mercato e le strategie sembrano costringere i produttori di strumenti per offrire cose sempre più libero e rilassare il paralizzante (ei sana ole) per attirare i clienti, ma alla fine della giornata strumenti commerciali sono alla mercé dello strumento di fornitori decisioni aziendali . Le aziende vengono venduti e fuse, intere linee di prodotti vengono messi da parte o sospesi, in ogni caso i miglioramenti richiederà il layout di cassa ad un certo punto. Così, per i miei progetti hobby voglio usare qualcosa che spero sarà domani ad un prezzo accessibile. Prendendo la visione a lungo termine, se possibile entro i vincoli di altri, voglio usare gcc, la Gnu C-compilatore, che è destinata a essere lì per il lungo termine. L'unico strumento per domarli tutti. Detto questo, sembra che per microcontrollori a 8 bit, che hanno alcune architetture piuttosto semplici o addirittura strane, gcc non è probabile che sia disponibile. E 'utilizzato per sostenere le cose come 8051, ma che è stato effettivamente abbandonato per il momento. E può essere che questo è il modo in cui sta andando a rimanere quanto vi può essere un conflitto fondamentale tra il piccolo microcontrollore e la moltitudine di lingue il compilatore sostiene e il tipo di architettura della CPU più potente è stato progettato per. Per fortuna c'è il mondo microcontrollore che è l'equivalente di gcc, il SDCC - Small Device C Compiler. Il che vi mostra la potenza di utilizzando standard e C - il mio strumento preferito non era utilizzabile, ma ho trovato un altro utilizzato dai professionisti Forse Im di parte, ma non vorrei usare qualcosa che è inferiore a quello che i professionisti utilizzano. Questo non è snobismo, è solo che mi aspetto che i professionisti di aver fatto il loro dovere quando si selezionano i loro strumenti e patatine. E, ancora più importante, è loro scelte, non il mercato hobbistico, che manterranno gli strumenti e le patatine vivo. È interessante notare, è il mercato consumer che a sua volta aziona i mercati professionali Siamo tutti hobbisti quando si tratta di scattare foto con i nostri IXUSes e il suo sviluppo della marcia dei consumatori che spinge sicuramente lo sviluppo di chip. Mac Evangelism Ora, so che la seguente sta per sembrare stupido e testardo, soprattutto provenienti da un ragazzo che gestisce Windows XP e tre versioni di Linux sotto Parallels su Mac OS, ma non posso farci niente: voglio fare il mio sviluppo embedded in Mac OS X. lo so, limita le opzioni, è più lavoro, non ha senso, ma la sua grande divertimento. Integrated Development Enviroment non Im un grande fan di sviluppo integrato (IDE) Ambienti - un buon editor, compilatore C e un Makefile lascia poco spazio per miglioramenti. Ora, mi permetta di qualificare che Im non grande fan di IDE specifici vendor proprietarie come CodeWarrior o VisualDSP. Sono tutti uguali, solo diverse, che è il problema. Tutti hanno più o meno le stesse caratteristiche, ma la loro attuazione in modo leggermente diverso facendomi re-imparare tutta quella roba. E quando si vede un unico fornitore a fare un lavoro migliore in un settore che ti fa veramente frustrato di utilizzare la copia sbiadita, fino a quando ci si rende conto che la migliore fa un lavoro povero su alcune altre cose. Quello è quando ho veramente frustrato. Quando uso un IDE voglio usare lo stesso IDE per tutto, non cambia come ho destreggio tra i progetti, o come il caso, quando la società IDE è rotto o viene venduto. Chiedete a qualsiasi utente CodeWright se si vuole sentire di più sfogo in questa stessa vena. Mentre molti dei IDE di proprietà, in particolare per i mercati embedded, sono decenti, Ive ha trovato nessuno che definirei buono. Un sacco di cose sono mal eseguito, come se gli sviluppatori si sono mai utilizzati per il lavoro vero e proprio. C'è un IDE in realtà mi piace, e che è Eclipse. Per inciso, si tratta di software libero ora anche se ha le sue radici nella IBM VisualAge per Java. Si ottiene così tante cose in modo giusto che a volte mi aspetto che ci sia un lettore di mente da qualche parte. Gli strumenti di completamento del codice e ri-factoring sono impressionanti, l'ergonomia dell'interfaccia utente lascia poco a desiderare, la ricerca e il codice strumenti di navigazione sono grandi e lavorare come una brezza. E 'uno spazio utente di grandi dimensioni ed è disponibile per tutte le principali piattaforme e supporta molte lingue. Vibrante e calci. E con il plugin CDT è ora un ambiente CC praticabile. È vero, il re-factoring, costruire e strumenti di ricerca per CC non sono ancora abbastanza buono come per Java, ma si continua a migliorare ed è già il mio preferito per la programmazione C. Naturalmente, nulla è perfetto e non è né Eclipse, ma mi piace e sembra essere destinata a un grande futuro, che è di somma importanza. Costi problemi costo in quanto tale non è un grosso problema, per una tantum progetto fa una piccola differenza, se un costo di chip 2 USD o 40 dollari, ma poi ci si è il danno co-tardi, gli investimenti in apprendimento e l'utilizzo che youve imparato . Se si impara a utilizzare una parte di 40 dollari, si rischia di usare ancora e ancora una parte simile e se si inventa la prossima trappola mouse grande parte 40 USD può fare o freno al progetto. E che hanno bisogno di ri-imparare qualcosa di così complesso un nuovo microcontrollore è sicuro di mettere un freno per qualche tempo, almeno per l'hobbista. Quali microcontrollore - Infine raggiungere in un primo momento sembrerebbe che non ci sia la proverbiale embarras de richesses ma data la mia vincoli sopra si riduce in realtà fino a pochi scelte. Naturalmente, non pretendere di avere un quadro completo della mutevole paesaggio microcontrollore e forse ho perso i nuovi entranti, soprattutto perché ho iniziato questo progetto alcuni anni fa. Quale sorta di dimostra il mio punto circa richiedono qualcosa che può essere fatto fuori insieme in un fine settimana e ha un futuro Ormai si dovrebbe vedere, anche se non si può essere d'accordo, perché BASIC Stamp e PICAXE non erano nemmeno in esecuzione in questa competizione. La mia breve lista di candidati per un microcontrollore era: Microchip PIC18F2455255044554550 famiglia Microchip sembra essere molto popolare tra hobbisti, ma io havent molto spesso visto in uso professionale. Ho nascosto il sospetto che il motivo principale per il loro successo è che essi offrono molti dei loro dispositivi in ​​plastica DIL pacchetti Le famiglie PIC più anziani avevano architettura decisamente strano e ostile che li ha resi inadatti per altro che la programmazione in linguaggio assembly o utilizzando la loro versione speciale di BASIC . La serie successiva 18F sembra essere più flusso principale e SDCC supporta entrambe le serie 16 e 18 del PIC. PIC18F2550 supporta USB, è disponibile in un pacchetto di 28 PDIP Hobby-friendly (o anche 40 pin), richiede un cristallo esterno ed ha 32 KB di Flash 2048 byte di RAM. Purtroppo, questo chip non era effettivamente disponibile quando ho preso la mia decisione e anche campioni sono stati impossibili da ottenere, altrimenti si potrebbe essere la lettura la mia pagina web intitolata Divertirsi con PIC18F2550. Ho effettivamente messo in un ordine per alcuni campioni, in modo da essere forse Ill riferire su di essa in un anno o due. Dal momento che Ive non usato non posso dire quello che serve per programmare in-circuito che voglio fare, ma la navigazione sul web si vede un sacco di opzioni software-saggio. Silicon Labs C8051F3XX famiglia Silion Labs ha alcuni chip molto innovative e io in realtà avere due chip sul mio tavolo mentre scrivo questo. La famiglia C8051F3XX si basa sul ben noto e ampiamente supportato 8051 set di istruzioni e oltre USB ha 16 kB Flash e 1024 byte di RAM e non richiede, nessuno, componenti esterni a zero, nemmeno un cristallo. Anche se Micochip scheda spiega che è impossibile fare USB senza un oscillatore a cristallo, sembra che Silicon Labs può farlo. Ora che è quello che io chiamo una soluzione integrata Parlando di oscillatori di cristallo, mentre un cristallo e le due calotte più resistenza richieste dalla maggior parte dei circuiti integrati sono un grosso problema che può costare più il microcontrollore Purtroppo, non è disponibile in un package DIL o PDIP il che significa che ho bisogno di ottenere una scheda adattatore o la progettazione di un PCB. Non c'è da stupirsi questi chip sono stati sullo scaffale per due anni a questa parte. Inoltre, in-circuito di programmazione tramite un'interfaccia filo di C2 per un tipo di mi ha messo fuori, perché non è possibile generare direttamente da una porta seriale o parallela il tipo di segnalazione che richiede. famiglia MC68HC908JB Per caso Motorola (ora Freescale) MC6800 ed i suoi fratelli e discendenti sono stati uno dei primi microcontrollori che ho imparato e la famiglia 68HC08 è una sorta di discendente upgradeddowngraded di esso. L'evoluzione della famiglia 68XX farebbe per un riflettere interessante, ma mi dispiacerebbe farlo qui, basti dire che il 68HC11 che una volta sembrava il futuro è ora considerato un vicolo cieco evolutivo mutazione. 68HC908JB è disponibile in un package PDIP 18 pin, che limita il numero di IO disponibile e richiede un cristallo esterno, ma supporta USB e ha 8 kB Flash e 256 bytes di RAM. Nel circuito di programmazione è possibile con la modalità di comunicazione seriale un filo basato monitor, che è facile da implementare con porta seriale standard su qualsiasi PC. MC68HC908JB8 è anche il più economico del lotto a circa 1,5 dollari in quantità di uno, la vendita C8051F320 per circa 6,5 ​​dollari e il PIC18F2550 viene venduto in tutto 4,50 USD, non che fa molta differenza. Per serio lavoro professionale del chip Silicon Labs sembra fornire migliore bang per dollaro in termini di essere il nucleo standard del settore con il minimo circuiti esterni, velocità di clock veloci e più di dimensioni di memoria adeguate. Per l'hobbista la famiglia PIC18 sembra molto attraente come fa la famiglia Atmel ATmega48 che è disponibile nel pacchetto di 28 PDIP Hobby-friendly. Degno di nota è anche la famiglia Atmel AT90USB con la sua memoria di 64128 kB flash, 24 KB di EEPROM, 48 kB di RAM. architettura RISC ad alte prestazioni con supporto USB 2.0 e davvero interessante caratteristica: bootloading USB. Purtroppo, non viene in un pacchetto adatto. Dopo aver detto che penso che la famiglia PIC18F sembra ideale per un progetto hobby Credo che ora sembra logico che la pagina è di circa HC908JB BTW c'è una logica in base alla quale Freescale nome le loro parti. Prendiamo ad esempio MC68HC908JB8, MC è ciò Motorola ha utilizzato per secoli per designare le loro parti, il 68HC indica che questo è un discendente del 6800 microprocessore originale ma in alta velocità CMOS, 9 indica che si tratta di un dispositivo con Flash ROM interna e 08 stand per l'architettura di CPU variante come nel 68 08. JB è la famiglia di dispositivi orientati USB e 8 al amout della memoria Flash nel dispositivo in kilobyte. Per l'ordinazione di fare attenzione alla ottenere la parte destra come questo è l'unica variante disponibile in package PDIP. Si noti che questo è oggi un prodotto senza piombo e non vi è un articolo fuori produzione che è altrettanto buona, ma impossibile da ottenere, quindi non lasciatevi scoraggiare se una parte viene interrotta, di solito c'è una sostituzione. Costruire l'hardware per iniziare a divertirsi con HC08 è necessario solo due chip micro, cristalli e una dozzina di altri componenti. La configurazione hardware qui presentato è molto simile a molti altri là fuori e non dissimili da quelle sulle note applicative per HC908. Im ripetendo principalmente le informazioni qui per il mio riferimento, non c'è niente di speciale in questa configurazione, ma se siete nuovi a questo le note può aiutare a andare avanti, dopo tutto il modulo dati è lungo quasi 300 pagine, con una mezza dozzina di applicazione note gettato in L'hardware è in realtà piuttosto semplice, chiunque dovrebbe essere in grado di saldare insieme su un Veroboard in uno o due serate. Questo potrebbe non essere l'ideale primo progetto nel campo dell'elettronica, come è necessario essere in grado di leggere schemi e tenere il saldatore a partire dalla fine fresco. Detto questo, questo è abbastanza tollerante e semplice da andare al lavoro, a differenza di alcune delle cose transistore analogico ho tentato e fallito con 30 anni fa. Quello è perché digitale è semplice, solo due livelli di tensione e grandi tolleranze. Le parti non dovrebbero regolarlo indietro più di 15 dollari complessivamente. Alcuni, come il connettore USB Device non-così-facile da ottenere può essere strappato da un vecchio PC. Parlando del connettore USB, una buona soluzione è di non avere un connettore dispositivo a tutti, ma per prendere un cavo USB normale, tagliare l'estremità del dispositivo e saldare i fili direttamente al Veroboard. L'hardware è costituito da fondamentalmente due parti: un adattatore bootload seriale ed il microcontrollore reale, vedere l'illustrazione seguente. There is no need for a power supply because for up to 100 mA we can draw the power from the USB port and for this set up well be using well below 30 mA here. The Bootload Adapter The bootload adapter converts the voltage levels of your serial port to match those required by the microcontroller and allows you to download software into the microcontroller as well as provides a handy way to debug and experiment with your system. It also provides the high voltage that is required to force the microcontroller in the Monitor Mode in which the downloading can take place. Below are the schematics for the bootload adapter. For complete, printable schematics scroll to the bottom. The bootload adapter is just a MAX232A and a diode that performs a logical OR function to combine the receive (RX) and transmit (TX) signals. This turns the serial communication into a party line where either end can talk to the other end but only in turns. The MAX232A is made for the very purpose of converting from and to the serial line -1212 Volt levels to the CMOS 0-5 V level logic. For this purpose it contains charge pumps that magically turn the 5 Volt feed into the - 10 Volt required. The HC908 requires that a high voltage of about 8 Volts is presented in the IRQ pin to force it into the Monitor Mode upon reset. The circuit presented here takes advantage of the MAX232A charge pumps to steal that voltage from there. The adapter is re-usable in the sense that it is no longer required in this project once the project finished so you may want to construct it separately for easy re-use. To your left you cas see a picture of my adapter. Below youll see the Vero-board layout I drafted for it (click the images for larger view). I usually dont go to the trouble of drawing a layout but I wanted to make sure I did not run out of space as I wanted this to fit into my nice box. The Microcontroller The microcontroller Ive used is pretty much self-contained. To function it needs just a few bypass capacitors on the power supply lines, an external crystal for the oscillator and one or two pull updown resistors to configure the Monitor Mode entry. It is also nice to have an LED so that there is something to experiment with as soon as the hardware is done. I also always include a LED that tells me that the power is on, which in this design is the red LED on the adapter. This LED also blinks as the serial communication takes place, which is both useful and comforting. Below are the schematics for the microcontroller. I havent included any actual peripherals at this stage to keep the schematics simple, but you are sure to find plenty of online examples on how to connect LCD displays, stepper motors, relays or whatever you fancy to put there. Note that Ive not yet personally implementedtested the USB interface part, but from documentation it appears that you should not need the pull up. nor should you need the serial resistors shown on my schematics. I constructed mine on a Vero-board, see below, in about two hours with just the schematics as a reference. If you are inexperienced it might make sense to draft a layout plan first. Setting up the Software Tool Chain For the software you need a C-compiler to compile your programs into machine code and a bootloader to download and burn the machine code into the microcontrollers internal Flash memory. For anything larger than a single file test program I highly recommend using make to automate the process. You also need a text editor any editor that can write plain text files will do, but Ill show you how to set up a really streamlined development process and professional Integrated Development Enviroment with Eclipse. And all this is free in every sense of the word. For the compiler we use SDCC which you can download from their web site at sdcc. sourceforge. In addition to the source code, pre compiled binaries are available for all the major platforms, so there is no need to compile it from scratch. (I need to praise the SDCC project for making a good job on this, because building it from the source, when I tried it, went according to the book, something that does not often happen with your average Open Source project.) So download the distribution (see the Snapshot section), unpack it and put it where you like, for this tutorial I use my own set up as an example and I keep SDCC in my home directory under the name sdcc. The full path on my Mac is then Usersnyholkusdcc and the actual compiler is at Usersnyholkusdccbinsdcc. Scary stuff - the command line Next we will venture to the dreaded world of the shell comman line interface, but dont worry, I wont leav you hanging there, but I do think it is usefull to know this side of life too. If you are a complete novice to the command line I suggest you read my Linux 101 for Dummies which covers the basics. When reading through this stuff here you may get the impression that you are going to do a lot of command line typing stuff. Not so, dont sweat it. Even if you are not going to use an IDE but your favourite editor and work from the command line, your minute by minute routine is going to be something like edit code, type make over and over again, not a lot of typing really. And even if you are using an IDE you need to be able to get grasp of the command line stuff to setup and trouble shoot the IDE stuff, when things dont go smoothly. A few tips that will make life easier on the command line. First of all you do not always need to type long lines, it is also possible to copypaste stuff from for example this web page to the terminal so that you are spared from typing and typing errors. Pressing the cursor-up key in the terminal window will bring back your previously entered line, which saves you from a lot of typing when you repeatedly need to try things. Press the up key several times to go back even further back in history. This is universal, basic command line stuff that is worth learning. Every programmer should learn the basics of command line even if they spend all their life using an IDE. Note that this page and the examples are written with Mac OS X as a reference platform so some things maybe slightly different in Linux and Cygwin, but not much, and should work almost verbatim. Much of this applies to pure Windows as well, but I wont be covering all platforms here. We are going to fire up the Terminal to get access to the command line but before we do that we do a litle tweak that will lessen the amount of typing we need to do. We will modify the PATH so that sdcc directory is always searched for commands whenever we type the name of a command. In this way instead of typing we can just type to invoke the C compiler. This needs to be done before we start the Terminal for it to take effect. To modify the PATH in Mac OS X you open the file. bashprofile in your home directory and add the following line. Your home directory is the folder with your username inside the Users folder. So open the file and add the following line at the end: If there is no such file, create it. If you are using Macs TextEdit as your editor always make sure that the Hide Extension and If no extension is provided, use. txt check boxes are unchecked when you save a file. Note that the file is invisible in Finder because it starts with a period. Also worth noting is that you cannot open files whose name begin with a . from within TextEdit, you need to do this from the command line with something like open. filename. Note that the shell used by the Terminal was different (from bash) in versions before Mac OS Tiger so setting the path maybe a little different on older Macs. If you paid attention you noticed that while we were messing with the path we also added the path to bl08 which we will need later. Next start a terminal session, on Mac youll find the Terminal application under ApplicationsUtilities and to start a session just double click it. After firing up the terminal you should see something like: Now to just see that the path setup was succesfull type and you should something like and about a hundred lines of other helpfull text. If you get something like you messed up the path setting or sdcc installation and need figure out what went wrong. Next we install the bootloader software bl08 which will be used to download and program the code into our microcontroller. To install it download the source code from here. unpack and save into a directory named bl08 in your home directory. To compile it you type the following: This should complete silently in about a second and you should see, with ls command, that there is now a brand new file called bl08 in your current directory. Your very first microcontroller software -- Blink LED Now we are all set up to compile and execute our first program, the embeded world equivalent of the all time classic first program, Hello World. Our first program will just blink a LED. Simple but oh so satisfying, I can still remember how it felt about 30 years ago when I saw my first microprosessor to blink that LED Those were the days. This is also the way professional bring up prototype boards, just do something simple like blinking a LED to see that the system is at least alive -- you cant run until you can walk, so you need to take baby steps first. To save you from typing I put all sample code on-line and you can download it from here. but for, now lets pretend you type in the following program with your favourite editor: and save it to file blink. c in the directory hc08demosblink. Your editor does not support colors Dont worry, them colors aint supposed to be typed in. I just colored the listing to make it look pretty. hc08demosblink directory with: And finally we can compile it with: This should silently produce, without any error messages, a bunch of files in the current directory, which you can verify with ls command. If you made any typing errors, the compiler will output error messages on the consoleterminal along with the line numbers of the offending lines. Take your cue from there, go to your editor and fix them. Among the files produced there should be one named blink. S19 . which is the actual machine code we have just compiled our C program to. The file is in what is known as S-record format, and basically it is just a textual representation of the 1s and 0s, in hexadecimal numbers, that we want to put into the Flash memory. If you want, you can open it with a text editor and see the hexadecimal stuff but there should be no need to do that. Now all we need to do now is to download and program the code into our target microcontroller. To do that you need to have a serial port connected to the bootload adapter and the USB cable connected between the target and your PC to supply power to the device. Before we can issue the download command we need to find out what is the name of your serial port. None of the modern Macs come with a serial port, so if you are trying this out on a Mac you need to install a USB serial port adapter. Dont forget to install the drives, see the adapter manual for that. The manual should also tell you the name of the port but you can easily find it out yourself. This is a trick worth learning as this applies to Linux and Cygwin as well, just type: This will produce a long list of devices, something like (Ive shortened the listing from both ends to conserve some screen space): Now we look for something with tty. and USB in it, and there it is, on the second column, last line but one, tty. usbserial-FTOXM3NX. In Linux the serial port is often called devttys0. Now, the moment we have waited for, silence please, maestro drums. Press the RESET switch to ensure that the target is in Monitor Mode, waiting for our stuff, and type: If everything goes as planned we should see something like: And the LED on our board should start blinking at the rate of about once a second What a feeling, time to celabrate, get me a tall decaf nonfat mocha latte with mapple syrup and foamy top. sprinkled with cinamon and chockolate shavings, Ive deserved it. This was such a memorable occasion that Ive even filmed it for posterity, dont miss it, click the picture above. If, on the other hand nothing happens, it is time to trouble shoot so you need to read the trouble shooting section at the very end of this page. Before moving on, it might make sense to briefly consider what we have just done. To help to discuss this Ive drawn the diagram below: Reading from left to right things proceed pretty much in the same order as in reality. First we have our program written in C in file called blink. c. which the C compiler SDCC compiles first into assembly language and then into a relocatable object code file. A relocatable object file contais machine code that has not yet been positioned in memory and which may contain references to subroutines and variables in some other, separately compiled, relocatable file. The process of positining the code in memory and resolving and patching those references between files is called linking, and is the final step before we get the final loadable and excecutable file blink. S19. All this takes place when we give the command sdcc. illustrated in the diagram. Also worth noting is that SDCC is the one stop shop for compiling programs, it is a C-compiler, assembler and linker, all in one package. Next the loadable file is downloaded to the target microcontroller using the bootloader software bl08. which loading takes place when we issue the command bl08. illustrated in the diagram. Moving On - Hello World While a blinking a LED is a nice and necessary first step. what we realy need next is an ability to debug our software. Debugging is the art of finding out why the system doesnt do what we told it to do. To do that we need get information on what our code actual does and compare that information with our expectation of what it should be doing. Ive done a fair amount of code writing on devices where the only output was a couple LEDs. Accomplising this does make you feel like a hero, but it doesnt make sense, so the first thing I always do in a new project is to set up some way to send text out of the device. When designing an embeded system it always pays to have serial port or some such on the device to get that text out when you are developing the software, and even later on, because when system device fails to perform as expected how are you going to find out what is the matter So, lets set up printf facility that allows you to output whatever you need, whenever you need. We are going to do the classic Hello World program, finally Doing that is pretty simple, create a directory named hello inside the hc08demos directory, and make it your current directory with cd hc08demoshello command. Rember that all this stuff can be downloaded so you do not need actually do this manually. In to this directory copy two files, printf. c and printf. h. You can get these files and read more about them from this page but right now you do not need to. Yes, there is a built in printf which comes with SDCC but mine is a pure C, light weight version, and I wanted to show off here Now create and type in the following code and save it under the name hello. c in the same directory: Now you can compile this by typing the following three lines: By the way, above is an example of how you compile and link a multi file project using SDCC, an example that I was unable to find anywhere when I started to work with SDCC. If you look carefully, and as a budding programmer you should always look carefully, you notice that the parameters passed to the SDCC are slightly different in this example than in the previous. Or actually they are the same but we are passing them slightly differently. The first two lines are used to compile only the files without linking them by using the - c option on the command line. Because the compiler generates code to set the stack pointer, the compiler needs to know the stack location and we thus pass initial stack pointer value using the --stack-loc command line option. On HC08 architecture stack grows downwards, so we pass the address of the top of the available RAM memory here. If you have an other variant of HC08, look it up from the datasheet. The last line links the two previously compiled files, hello. rel and printf. rel together to produce a loadable code module hello. S19. To do this the the linker needs to know where to put the code so we pass this info to it using the --code-loc option. This is typically the lowest address of the Flash memory, again refer to the datasheet. Note that it is always ok to pass both options to SDCC regardless weather you are just compiling or linking. Note also that with some different target architectures in SDCC the stack location is actually needed in the link phase, not in the compile phase, so maybe the best strategy is to always pass all parameters. But all this typing is getting a bit tedious, so I think we are ready to introduce Makefiles. Make is traditional Unix tool that is used to automate the compiling of programs. Any non trivial C program consists of several source code files, each of which needs to be compiled separately and then combined into a single executable. Thats what we did above, the two first lines in the example compile the two source code files and the last one links them together. Now we use make to automate this. Mac OS X supports make out of the box so there is nothing to install, and so do most Linux distros, in Cygwin you need to install the C-development tools but I wont be covering that here. To use make you create a file named Makefile into which you put rules that tell make how to compile and link your project. You then invoke make by typing make and, well, that is it, it compiles and links your program, it is even clever enough to compile only those files that need to be compiled, a big fx in project where a full build may take hours or days Using make is something that all C-programmers should learn to use and should use, none of your infernal IDE specific managed builds that you have no control over. Make is universal and transportable accross operating systems and very popular so it is worth investing a few minutes in the basics. So create the following Makefile. note the Capitalization, in the hello directory: Once you have the makefile in place you can make it by just typing: Which should result in the very same commands to be executed and displayed on the Terminal as you what you would have entered yourself manually. Now all that is left to do is to execute our litle Hello world. So press RESET on the target device and type the following command to download and execute the code. Note that this line is slightly different from the previous command because we want invoke the bl08 built in Terminal Emulator, so that we see what our little beast is outputing to us: This should produce the following output on your terminal: And so on and so. Bring another latte and this time make sure its hot enough and the crema gusto properly made. To round up this Hello World demo, lets review how we put together the hello program, refer to the diagram below: This is quite similar to what we did with the blink software, only this time we compiled our hello. c program and the print functions it uses from printf. c separately via the two sdcc commands and finally we linked them together using the sdcc the third time, as illustrated in the diagram. But there is one more thing to do before everything is set up the way I like. While using the command line is actually as simple as typing make, it is not the way I want to work all day long. because there is a better way. Real Programmers Do It with Eclipse and go to Download page and select Eclipse IDE for CC Developers . this is a nice little 67 MB download. Double click on the downloaded file and Mac will unarchieve it into a single folder Eclipse which you can then copy where ever you want to keep it. Launch Eclipse by double clicking the icon. Create a workspace by entering a path to where ever you want it to be generated. Close the wellcome tabview by clicking the X - shaped icon. Eclipse is now installed and ready for action. Creating a Makefile based C project in Eclipse Create a new C project from the FileNewC Project menu and in the C Project dialog that opens do the following: Into the Project name entry field enter a name for the project, call it hello . Uncheck the Use default location check box. Into the Location entry field enter On the Project types list, expand the Makefile project and select Hello world C project It should look something like this (click image for larger view): This will produce an errorwarning dialog or two because the Makefile already exists, but just ignore them by cliking OK. Now the situation should look pretty much as follows: Make sure that the Console tab (Eclipse calls them Views) is visible, if not, click on it. If you cant find it, go to WindowShow ViewOther. menu and search for it by typing console in the search box. This tabview is the Eclipse equivalent of the terminal command line we just left behind and youll see the compiler print its error messages there and even the output from our target device. Remember the printf exercise we did above You guessed it, even that output will appear in the console window Just for fun, you can now build the project, from the Run menu select Build All and you should see something like this appear in the console view: From now on, that is all it takes to build you project no matter how big it gets. Next we will introduce Eclipse and the bootloader to each other. From the RunExternal ToolsOpen External Tools Dialog. menu lets open the external tools dialog. In that dialog, on the left side panel, click on the row which says Program and then just above it, click on the little document shaped icon with the plus sign on it. This will create a new tool with a default name. Into the Name entry field type run-hello or what ever you fancy. Into the Location entry field enter the full path name to the bootloader, ie something like Into the Working directory entry field enter Into the Arguments entry fieldbox enter the same command line parameters we used when we did this from the terminal, i. e. Now it should look like this: Click on the Apply button to save the changes. Now push the RESET button on the target device and click on the Run button and you should see in the Console view that first the project is quickly built and downloaded and then the familiar Hello World, this HC08 talking output should start ticking in the window. All you have to do now to build, download, program and execute you code is to select RunExternal Toolsrun-hello from the menu. But wait, lets take it one step further. Select EclipsePreferences. from the menu and open the Preferences dialog. In the the search entry field type key . From the short list that will appear select Keys . On the panel that lists all the commands scroll until you find Run Last External Tool command and select it. Click inside the Binding entry field and then press the key on keyboard you want to use. Now you can go through your whole development cycle of editing, compiling, linking, downloading, programming and executing by with a single key press. Now how cool is that Understanding the Code This page is not a tutorial on C programming, which you can easily find elsewhere, but I felt that a short line by line walk through the code might help you over some microcontroller related rough places not covered by standard C tutorials. Before I go through, line by line, the code Ill show you how basic inputoutput and peripheral control is typically handled with C in microcontrollers. Brief Intro to Memory Mapped IO Some processors have special instructions for doing output but much more typical is the use of so called memory mapping. Memory mapping simply means that the hardware is so wired that writing to a particular memory address will cause some action to take place in the hardware. Typically there is a hardware latch or register attached to that address and the outputs from that register control various things such as output port pins. In this way controlling output devices or peripherals is as simple as assigning a variable This concepts also applies to input and reading of peripherals. A few words of caution to store at the back of your mind though: memory mapped registers are actual hardware, not just memory. Merely reading them may cause some special action and it is not always possible to read back what you just wrote into a register, some registers are read only, sometimes the same address accesses different hardware depending on weather you read or write. Check your datasheets In MC68HC908JB8 there are 64 of these memory mapped at addresses 0x0000-0x003F. Bits in these registers controls all the aspects of the microcontroller from simple pin output to clock frequencies and memory protection. Every byte in memory is made of eight bits each in either 1 or 0 state. This makes for 2 8 256 different combinations. When we are using these to do calculations this is typically treated as the numeric range -128..127, using what is called twos complement arithmetic. But when we are talking about memory mapped registers or IO ports, we are talking about individual bits which are indipendent of each other, yet we have to treat each byte which is a group of eight bits as single value. Each bit has some specific meaning in the hardware, this meaning being explained in the datasheet of the microcontroller. What we need to do is to be able to change those bits individually. Full discussion of binary arithmetic and bit manipulation is beyond the scope of this page, but here is a quick cheat sheet. It is convetional to visualize a byte as a box with eight cells numbered them from right to left as follows. There is a strong tradition to use hexadecimal numbers instead of decimal numbers when dealing with bits so Ive used it here, just better get used to it. Walking through blink. c What follows is a blow by blow treatise of the code. Lets rip this line appart and see what each part says: This defines a variable of type char giving it the name PTA. For most purposes you can equate char as byte in your own mind, with the integer value in the range -128..127.This is not the full story but let is stand like this for this discussion. This is not standard C, this is a SDCC specific extension. I dislike these extension but evidently I have been succumbed to use them. The data tells the compiler to place this variable in data (RAM) memory which is the sort of memory that will loose its contents when the power fails, as opposed to code (ROM) memory which is retains its contents without power. The at 0x00 tells the compiler not to decide where to put the variable but to put it at the given address 0x00. But where did that address 0x00 and the name PTA came from I looked them up from the MC68HC908JB8 datasheet, which tells me that there is a memory mapped IO port A named PTA in address 0x0000. Memory mapping simply means that an output port is so wired in the chip that as far as the software is concerned it looks like any other memory location. To output something to the port it is only necessary write to that address. Memory mapping is very common in microcontrollers as it avoids the need for special IO instructions in the chip, simplifying both software and hardware and makes expansion easy. This tells the compiler that it must not optimize away any access to this variable. Normally, the C-compiler is free to deside, within certain bounds, when and if a variable value is updated. After analyzing the code the compiler may decice that there is no need to write a variable at all because the value is never used. This in no way alters the logic of the code, but if the variable is an output port it is vital that it actually gets written, because even if the code never reads the value, the LED certainly wont turn on without the write So it is vital that we declare the variable volatile. Quite a lot of information we learned from the first line These two lines just define two more memory mapped registers, called CONFIG and DDRA, just like the port A stuff above. These are called registers as opposed to ports but technically and practically it is all the same, all look like ordinary memory locations. This line defines a function called main which is where the execution of the code starts. It looks rather complex, but you do not need to really understand what it says, every C program should have one and only one main function and it should look exactly as it is here. Whenever writing code, just copypaste it from here. This line turns off the watchdog feature in the HC908JB. Any computer may get hungup or start running wildly because of a glitch, alpha particle, design error or software bug. In those situations someone has to press the reset button. This is where the watchdog, or as the datasheet wants to call it, Computer Operating Properly (COP) feature kicks in. It is a simple circuit that detects that the software is running wild or hangup by seeing that the COP register has not been cleared for a while, in which case the watchdog will reset the whole microcontroller. This is an essential feature in any embedded microncontroller system which is designed to run for years without intervention, however, it is a pain when debugging and developing, therefore we turn it off here. Someday, when the code is finished Ill turn it back on by leaving out this line out. The name DDRA stands for Data Direction Register port A and it is a register that controls weather each of the eight pins in the port A are input or outpus. For each pin in the device and each bit in the PTA port there is a corresponding bit in the data direction register. Writing a 1 bit into any of those bits will turn the corresponding port pin into an output. Here we turn both bits B0 and B1 into outputs by writing 3 into the data direction register. This also makes the other pins inputs as we write 0s to them, because I did not bother to use the form DDRD 0x01 0x02. Mayby I should have used it, now Im teaching bad habits here. Here is what a typical microcontroller main program looks like, this is a loop that loops forever, after all, what would the microcontroller do once it finishes its task Wait for disposal No, it keeps waiting for more of the same stuff to do. Note the opening brace five lines down, which define the loop body i. e. those statements that are looped while the condition is true. which in C is anything that is not zero. This line defines a local variable i which we will be using a few lines later to waste some time by looping doing nothing. A local variable is a variable that only exists while the block where it is defined is being executed. It is a handy way to declare variables that cannot get mixed up with other variables in your software. Remember, global variables are evil. The variable is defined as unsigned int giving it the numerical range of 0..65535 as oposed to normal signed int, which has only the range of -32768..32768, which was rather small for the delay I wanted here. This line toggles the Port A bits B0 and B1 in effect turning On or Off the two LEDs in our circuitry. These two lines form a loop that will increment the value of our local variable i from 0 to 50000, executing the rather obscure statement PTA each time. The obscured statement actually just says that the compiler should read the port PTA and throw away the value. I put it into the loop to waste some time and to prevent the compiler from optimizing away the whole loop Without that, the compiler might have decided that the whole loop was superfluous as the value of i is never used anywhere outside the loop and it would have been quite legitimitate for the compiler to optimize it all away. These are the closing braces that end the while loop and the main function. Understanding hello. c Every non trivial program should be broken into smaller chunks for maintainabilety, managabilety and sometimes for re-use, be it that re-use is the wholy grail of software development that often is best not persued. Every seriour programming language also provides someway of organizing the code into separate chunks. In C the facility is not very elegant or sophisticated, but it is effective and powerfull, ugly but matches the style. This facility is called the include preprocessor directive which effectively inserts the given file in that place of your source code. Here we are including the file printf. h which includes the public declarations of the functions and variables in our printf library. As I said before there is also a standard printf function that you can use, in which case you would be including the standard header file stdio. h here. See any tutorial text on C for details. This is the same stuff as in the blink code above. Here we define and declare, to be grammatical, a function named putchar that takes one argument (the char x part), a character to output, and returns no value (the void part). This function, or actually it is a subroutine because it returns no value, is needed and called by the printf facility to output a character to terminal. How did I know I needed to provide this Well, I read the documentation in the printf. h file, thats how. This line is not necessary and has no function, but nevertheless I explicitly wrote it with some pain My golden rule in programming is that all compiles should be clean, in other words that they should result in zero number of errors and warnings. In this way I know that when I see a warning it really means something. I highly recommend this practice to everyone. Now in this situation here, in the following, youll see that the body of this function is written in assembly language, not C, so the compiler does not understand anything about it. What the compiler understands is that the argument x is never used, and it complains with a warning. The compiler is within its rights to complain but the code is correct so I need silence the compiler to satisfy my no warnings rule. There is no universal way to get rid of a particular warning, although most C compilers will allow suppressing of particuar warnings via command line options or pragmas. What Ive done here is that Ive told the compiler to read the argument x casting away the value to void. In practice the compiler will then optimize this away so the line produces no code, but this usually prevents the compiler from complaining, because Ive used the variable. There is no guarantee that this works with every compiler, but so far it has worked with all the compilers Ive come accross, in any case it is legitimate C and should always compile and does not clutter my Makefiles with non portable compiler options. These lines insert what is known as inline assembler code. To understand it, quite a lot of background in assembly language is required, so I wont try to explain it in detail here. Inline assembler is a last resort, most of the time best avoided even if you are tempted. What these lines say is that clear the bit 0 of port A ( bclr 0,PTA ) and then call suboutine at address 0xFED6 ( jsr 0xFED6 ). This addresss ( 0xFED6 ) is within the HC908JB8 factory programmed mask ROM memory and contains a handy routine that will output a character in the accumulator A through port A pin 0 using standard async protocol at 9600 baud, which is quite a handy routine to know about, because this particular model of HC908 has no serial port How did I know that there is this routine that I could take advantage of How did I know how to call it and how the interplay with C with argument passing works Well, first of all, I deduced that there must be some such routine there, then I uploaded the machine code from an actual chip, disassembled and reverse engineered it and then I read the C compiler manual and experimented with the info I had. Took me only about eight hours to figure out those two hex bytes Do not let this scare you, you are unlikely to ever require this sort of wizardy, this is about the only thing I can think of in this context you need something like this. And since it is presented here, all you need to do is to use it. Thats the closing brace for the putchar function. All this is same stuff as in the blink code above. And this calls the printf function from our printf. c file passing it the Hello.. text as argument. I guess you know these by know. Understanding Makefiles The whole make system is actually quite complex but you can master the basics in just a few minutes, there is no need to set out to learn it all, just learn as you go. Simply put, make system is a program called make which when executed reads make rules from the file named Makefile in your current directory. The basic form of a make rule contains two lines of which the second one is indented and it looks as follows: This describes a dependency between three files. saying that if either of the files on the right side of the colon, hello. h and hello. c. is changed, then the file on the left side of the colon, hello. rel. needs to be rebuild. To second line is the command that is used to rebuild that file. Basically, that is all there is to it, you could describe your whole build process with a rule for each C file and one rule to link them all. Well done, in one minute you have learned to read and maybe even write Makefiles. If you take that route, you pretty soon see that all your rules are more or less similar, so you may think that would it not be nice to write some sort of generic rule to handle the bulk of these things, just adding some special rules by hand. And of course you can: Basically this rule says that every. rel file depends on the corresponding. c file. And on the second line we use the to refer to the left side of the dependency rule and the refers to the file on the right side of the dependency. Simple realy. Often you encounter a generic dependency rule that has no second line, like: In this case it just describes the dependency but the commands to rebuild need to be found from some other dependecy rule that pertains to the file in questions. This makes sense, you do not want a file to be built twice, no point in that, and also you do not want to create opportunities for inconsistencies by having the actual build commands in two places. The file on the left side of the colon in a dependency rule is techically called the target and it is actually what you should specify on the command line to build it when you invoke make. If you specify nothing on the command line make defaults to the phony target all. A phony target is not file at all, but you can use them just the same, which makes for all sort of handy tricks. In addition to rules we can also use variables, actually macros, to make writing the rules easier and more maintainable. Wading Through the Makefile So now we are ready to walk through our very own Makefile. Here we create a macro named SDCC so that when ever we need to refer to our C compiler we do not have to type all that long path name, and, more importantly, we now have just one place where to change it if the location changes. Also, using a full path to the SDCC executable here makes it unnecessary to set the enviroment PATH correctly when running this make from within Eclipse. Here we create a macro OBJS to hold all the names of all those relocatable files that our program consists of. Every time you add a new file. c to your project, you add file. rel here. This makes it simple to add new files to your project. That is all there is to it, well, almost. An other macro LIBS is created here that holds all the libraries that we want to link into our program. It needs to be separate from our own program files because typically we do not have source code for these and thus cannot or do not want to build these. In our example we have none. By using TARGET in our make file instead of just typing hello I have abstracted the name of our main target so that it is easy to change. Changing project names is sometimes necessary but can be a royal pain, Ive yet to figure out how to do that on Visual Studio All C compiler support hundreds of options to tweak this and that, so to keep our makefile managable it makes sense to use a macro to hold these parameters. This is the rule that says that any relocatable object file. rel depends on the corresponding. h - file. This rule has no commands because the actual commands will be found from the rule for the actual source code files, just below. This is the actual rule that compiles all our C programs files. See how the use of the two macros SDCC and SDCCFLAGS makes this much shorter. And this rule finally puts it all together saying that if any of the files that make up the program has changed, including this Makefile. then rebuild our program by linking all the files together. See how the macro OBJS makes life much more bearable, already on these two lines we have used it twice, imaging what a maintenance nightmare if would be without a macro, when someday we have dozens of files in our project. And finally, this makes use of the defaul phony target all so that we can just build the whole thing by typing make. We are almost done, but I need to confess that Ive left one or two things out of the makefile to make it easier to grasp. As presented here the rules do not cover the very real case in which a C - program file includes, via the include directive, another file, making it dependent on that file too and requiring a recompile if any of these files changes. This should be reflected in the rules and has to be done manually, there is no generic rule to handle this, more is the petty, but the C include and separate compilation facility is rather rudimentary. So in our example case you should really add the following rule: Much as I hate this phrase: I have left this as an exercise to the reader. It is also customary to have sort of utility phony targets in make files like: The compile process typically leaves a lot of intermediate files around and I, for one. want to keep my directories clean, so I include a clean-up target like above which allows me to delete all non essential files from the project with a simple command make clean before I archive or backup it. Now you are on your own Thats it, you are done, your first microcontroller based on the 68HC908JB8 chip is up and running, the bady is crying out letting the world to know that lungs are fine and the heart is pumping. You are set up for life and the things you learned are applicable to countless other microcontrollers out there. Time to think what this baby will do when grown up, take it collage, teach it a few tricks and hey the next big gizmo on TV-Shop could be yours and you a millioner Time to update your resume and get a career in embeded microcontrolles P. S. - Full schematics Here are the full schematics I promised, click for a printable size. Note that Ive not yet myself implementedtested the USB interface part, but from documentation it appears that you should not need the pull up. nor should you need the serial resistors shown on my schematics. At this stage, I would not put in the 1.5 k pull up, as this will cause your Mac to recognize the device and try find a driver for, which might create a problem, dont know yet. The serial resistors should do no harm, but Ive seen them used, so I included them in the schemantics, although you should be able to do without them. Looking at the schematics you may see an additional twist, Ive added a transistor connected to the DTR line of the RS232 connector. This allows the bootloader bl08 to automatically reset the microcontroller before downloading, saving you from the trouble Just add the following option to the command line: This will toggle the DTR line for 1 second or 1000 milliseconds before the download begins. P. P.S. - Trouble shooting I promised some trouble shooting help. Being mainly a software guy Im not really qualified to help in hardware stuff but here are some tips Ive picked up over the years. Some general hardware related trouble shooting tips I usually take baby steps anyway, even if I think I could just wire and fire it up and get it to work. Taking it step by step brings familiarity and confidence which always helps. First, before connecting any power, I double check the circuitry, tracing the schematics with color pen to make sure Ive connected everything right. In Veroboards it is also too easy to forget to cut some traces so I keep a special watch out for unwanted connectionsshorts. I also mentally check the schematics once more so that it all makes sense. Too often you see schematics, especially on magazines, that have some obvious errors in them. The most reliable schematics are those that have been drawn with CAD program and then turned into a PCB board and that somebody has actually built it. When you see a working bord produced from a CAD design way without any patch wires, then you can think that the schematics is ok. Unfortunately this does no really apply for one-offs and new designs, like on this page. A visual check should also be performed checking that all solderings look alright and that there are no cold solderings. Re-melt all suspects. Also check for solder beads and off cut component legs which are easily caught up between pcb traces and component legs during manufacture. Before connecting the power make sure the voltages are all right. Elementary, but so necessary. If you have a lab power supply with current limit it often makes senso to the set the limit close to zero and then carefully allow more current until the voltages are in the proper range. If circuit takes much more current than what you expect you should disconnect it and find out the cause. If you are not using a lab power supply with built in amp metere then measuring the current consumption requires that you can insert the meter in the circuit, which is bother, if you did not have the foresight to allow for it. On most hobby electronic circuits a finger test is usefull. Most of the parts should not be running hot, and you can test this with you finger, they should just feel warm. Mind you, some power components are designed to run hot, so do not burn you fingers And before you poke anypart of you body to any circuit make sure the voltages levels are safe. Take care In this project youll be using the power from your computers USB port, which is current limited. This is both good and bad. It is good in that it protects your computer and to some extent your circuitry. Its bad in that a maximum of 500 mA is available for your circuitry and actually, according to specification, only 100 mA is available unless your device requests it, which requires that your device is up and running and able to that. In any case you want to be carefull when connection your own stuff to the USB port as the repairs to the mother board are expensive (can you say I need a new laptop mother board). Once you connect the power you can check some voltages with a digital Volt meter. Make sure it is not in the Amp setting or youll be creating short circuits The HC908 IRQ pin needs to be 2.5 V above the 5 V supply voltage, at about 8 V, for the part to enter Monitor Mode. The crystal oscillator pins OSC1 and OSC2 are at about half of the internal 3.3 Voltage, on mine the meter showed 1.8 V. Off course this does not prove that the oscillator is running, but if you do not have an oscilloscope that is the best you can do. If you do have an oscilloscope why not have peek to ensure that it is running at 6 MHz, producing sort of sine wave at about 1 Volt peak to peak amplitude. All the HC908 pins with pull down resistors should be at 0 V and all those with pullups should be at about 3.3V, note that the pull ups must not be to 5V The HC908 internal voltage regulator output should show about 3.3 V. And remember to check that 5 V supply Always check the cables, industry is full of anecdotal evidence of engineers flying around the globe just to plug it in Some serial port related trouble shooting To check that your serial port works, download a terminal emulator, like Z-term, and set it up to use the serial port. Type something, and if what you are typing is echoed on the screen, then you have a local echo On and you need to find out where to turn it Offf. Once the echo is off you should not see on the screen what you are typing. Now take a male 9 pin D-connector and connect a wire between the RX (pin 2) and TX (pin 3) pins and plug it into the serial port. Now type something and you should see what type echoed back on the screen. Next remove the connector and plug in the bootload adapter to the serial port. Also connect the adapter to the target device as it takes its power from there, which also implies that the target needs to be powered up ie connected to the USB port. You should now be able measure that the 8.2 V voltage is ok and that LED is on on the adapter, the that the serial RXTX line between the adapter and the target is at about 3.3V. Now set the terminal emulator to use some low baudrate like 300 bauds and you should see the LED on the adapter to shimmer as you type something. try sign because it has a lot of 0 bits and will thus be more visible on the LED than some other characters. You should also see with a volt meter that the TXRX signal fluctuates as you type. Dont forget to quit the Terminal Emulator once you are through, otherwise the serial port will be busy and the bootloader cannot access the port. You can learn something by trying the bootloader bl08. On the command line type bl08 - c devtty. usbserial-FTOXM3NX - b 9600 - t jb8 - e This will try to connect to the target and erase it. If the seria port is busy or the port name is wrong or is not a serial port you should get: Failed to open seria portdevtty. usbserial-FTOXM3NX: No such file or directory Check that no other instance of the bootloader is executing (you can do this from the commandline with ps - A command that will list all running processes, if you see one, make a note of the process id number and kill it with kill processid ). Also make sure that some other application is not using it. And of course make sure the drivers are properly installed. If the adapter is not working or not powered up you should get the following error message: Serial port failed to receive a byte, read returned 0 Which indicates that when the bootloader sent out a byte it failed to receive it back which is what should have happened regardless of weater the target is functioning or not. See above for basic serial port trouble shooting. This error is an indication that loop back is not working and either your adapter is not working or the target device is holding the line. If the adapter is working and powered up but the target is not responding you get: Loopback failed, nothing was received Check that the condition for succesfull Monitor mode entry are present, these typically are that the IRQ pin is at 7.5 V or above, and that certain input pins have pull ups or pull downs. Check from the datasheet. Loopback failed, sent XX, got YY The the target probaply is ok as there was some responce but the baud rate was not correct. Check the baudrate you used against the device data sheet and the boot mode you are using, the baudrate depends on your oscillator speed and on some HC908 devices more than one baudrate is available and this is configred with one or more input pins upon reset. Unexpected data from serial port: XX this is an indication that someone, most likely your target device, is sending stuff to the serial port. Maybe you forgot to RESET it before you tried to bootload. If you have done your homework and it still does not work you can always try some Freescale users forum or as a last resort email meNRF24L01 real life range test Today I was working on a project using NRF24L01 chipset and I decided to verify the test range of this small device that you can buy as a breakboard on ebay. I bought a pair some time ago and bought recently another for my new projects. The modules are different but have the same pinout so it is easy to change them for testing. Both modules are new version, NRF24L01 and not the old version NRF24L01. The new version is capable of doing 250KBPS low speed and the old not. The newest is the black on the left of the picture, seems better quality and a little shorter. So I tried this one first on two Arduino powered by lipo battery. 1st Arduino act as client sending payload (8 bytes) with ACK enabled. The 2nd Arduino just display the payload received but do not send back anything (except the ACK but the module doing this in hardware, so nothing to do execpt enable this mode). Then, I went outside in a clean area. Leaving the receiver at one point and starting moving with the client in my hand until it started to display that it was loosing ACK on the OLED display. Quite surprised, It started to loose ACK from about 30 meters and modules vendors claims it work until 100 meters. Well as usual in IT, theorical performance never reached. So I decided to try with the 2nd modules (the green on the right of the picture). That was better I succeded to go for about 50 meters. The bad thing is that I do not remember where I bought these modules, shame on me. This conclusion to says that every module do not have the same range and performance. If you can choose, take the green one, about 30 better, just good to know. To test further, I decided to buy the same modules with Antenna so I can see the range difference. And I also bought the new modules with Power Amplifier and Noise Suppression (PA-LNA) that claimed range to 1KM, wooooh, need to test that. Edit of September 8th. I succeded to improve the range with a Payload size of about 8 bytes (I had 12 before), this gave me about 80 meters range in open air, I8217m quite happy with this range. This is very interesting that lower payload size higher range, but that make senses. So if you need range and more data to send, the idea could be sending two packets, if power is not a issue of course. By the way, in house with walls or other will decrease the range. Edit of September 12th. I received the new modules. Excited, so I plugged them onto my range test boards, put a lipo on boards and give it up. The NRF24L01-antenna module gave me excellent results in house, no more 8220dead zone8221 and testing outside gave me good results too. But my road is now not enough 8220long8221 to do real tests in open air, I can8217t have more than 100 meters in open view, so going far from 100 meters put other houses on the way and the test is different, I need to find a huge field around for testing open air -). I will update this post as soon I will have tested. Here are the picture of the modules below, I will do more test with them and keep blogging on it. Post navigation Hi Charles, thanks for sharing use full information. I have a doubt, i was working with nrf24l01 module which are working fine. Recently i bought nrf24l01 pa lna long range modules, will this modules work with the same nrf24l01 code or any changes i need to do in the code when i tried pa lna modules with same code it was working but distance is not even 5mtrs, i was surprised with this range as it suppose to give 1000mts in open area. Forgive me for my english. Yes, the code is the same for PA LNA, such as the connector. I8217have done some test with all the different modules, and what I noticed so far is that module with integrated antenna on PCB can reach about 50 meters, the modules with external antenna rocks, I can achieve about 150 meters without any problem, my other surprise (bad) was the PA LNA, it was about 250 meters, so from my point of view, use the modules with external antenna, it is the best pricedistance. I would be happy if someone can confirm my tests, it should be very interesting to see other users real distance. For my tests, I used payload of 2 bytes at 250KBPS speed, in outside open clean area. Thanks for your reply Charles, i did a test in Indore with nrf24l01 with out antenna module, with one concrete wall in between, it reached 8 8211 10mtrs with out packet loss. I will reply with open area test with in a day or 2. i though nrf24l01palna will give me at least 30mtrs in Indore but no success. Hi Charles Today i performed open area test with nrf24l01 module with integrated antenna, got 45 to 50mtr with around 5 packet loss while moving. if i am not moving and facing the receiver then no packet loss. I am not able to find this module with external antenna in my country. Yes, I have exactly the same results, sounds good and correct if we have both the same. Thank you for the head up. I8217m wondering if cutting the PCB antenna and replace it with small wire antenna could improve the range, now that I have test board and firmware file hallard. mearduiled I will try to do more testing. Believe the green version have 10 pins (including 2VCC amp 2 GND instead of 1) so do we need to supply the power to both pins or just 1 Good point, I took a picture from ebay vendor and did not notice that. The one I really have does not have 10 pins but 8 so it didn8217t came to my mind. But looking the picture I can see that the 2 new pins are for gnd, but probably not mandatory to connect them since GND already present. I think the best answer could be, 8220testing8221 I have tested both modules, the black and the green, and found the green module (with the 8216question mark8217 PCB antenna, as opposed to the 8216zig zag8217 PCB antenna) to be much more reliable. In fact, I found it almost impossible to get any reliable packets at all through the black modules. Indoor range for the green module, however, is quite limited (lt5 meters) and quite sensitive to position. I would love to know if attaching a wire antenna to the PCB would improve the range. And if so, is the best result on the sending, or on the receiving end If I find anything from my tests, I will post them here. Exact, the green module is far better, but I8217m really surprised for the 5M indoor range, I8217ve got more than this. What speed do you use and what is your playload size for transmissions I did not tested yet with soldered cable instead of PCB antenna. Thanks for this information, it is very helpful. What would the effect on the range be if a 24l01 module with an antenna is used on the master unit and normal 24l01 modules (without antenna) are used on the slave units Have you done any tests using this configuration Will the range increase or must the slave units also use the module that includes an antenna for noticeable results In my case, the slave units would send data to the master unit most of the time. If the range is efficient, this could reduce the cost even more. I would like to know if it would work before I decide which modules to buy. Thanks and kind regards Yes I8217ve done this kind of test (but very quickly so this information could not be accurate) and as far as I remember what I noticed was: For example, let admin simple module No Antenna get 100 range. Receiver And Emitter with Antenna get about 200 range (so twice of no antenna) the best choice. Receiver with antenna and Emitter without antenna get about 130 range (so 30 on increasing distance) Receiver without antenna and Emitter with antenna get about 130 range (so 30 on increasing distance) So we can conclude that one antenna increase range, whatever on the Emitter or Transmitter If someone done same tests, I8217d like to share. I also have both the black and green styles of nRF24l01 transceivers, and have had similar issues where the green seems to be a bit more reliable. My bigger problem with testing these isn8217t how far they reach, but how close they can get without failing. While testing I have to have one on my desk, and the other in another room on a long cable. If they are too close to each other they don8217t work. Another proximity problem is with all of the other 2.4Ghz transmitters in the area, including my neighbors houses. One of my testing schemes was to have the remote transmitter on the other end of my house, and use a bluetooth serial transmitter to get the feedback from the nRF24l01 at that end. Oops The bluetooth transmitter interfered with the nRF until I put it on a long cable about 5 feet away. The WIFI router at the end of my desk also interferes with this, as does my neighbors. I have to be picky about channel selection so I don8217t get stomped on by the WIFI routers using the same basic frequencies. The scanner example is quite illuminating, and goes pretty well with a testing app I8217ve used for WIFI signal strength on my tablet. It is a challenge testing when discovering that there are a lot more 2.4Ghz signals floating around than just what the nRF24l01 is transmitting. And that all the other devices interfere with what I8217m trying to receive. Distance-wise I have found that the green transceivers are good for about 100 feet through the walls of my house, and the black for about 70 feet. FYI 8211 I got both styles through EBay. Thank you for your comment, I just discovered the site you are talking about, this is a great site for buyers like me, I think I Will order soon Correct on 10 pins modules the wiring is different and I was not aware of that. The adapter seems the good solution and quite cheap. Let us Know of this module has better range than the others. Could be interesting. I wanted to build a project and I have found on the website the item 8220MK NRF24L01 SI24R01 power enhanced version 2.4G wireless module8221 ( wayengineerindex. phpmainpageproductinfo038cPath7580038productsid3442 ). Any idea what MK stands for And SI24R01 I couldn8217t reach much through the web however. Is it the same one you got, the black, supposedly longer range one And if that8217s the case, how different is it from this one wayengineerindex. phpmainpageproductinfo038cPath7580038productsid865 Idea is they have so many choices and I am looking for low power, high range and most probably available in high volume. Could you direct me from you ordered from Thanks for the post and your comments by the way, it answered a lot of the questions I had. Humm, it seems that the 1st module you describe is the new one, I was not aware that there was new model. I do not know the difference but seems to need take care to drive it. May be you can achieve more distance with it, need to be tested. So as special 8220driving8221 is needed I suggest you use the 2nd one, that way you will be sure that existing libraries are working well. May be testing the 2nd then when all is working try with the 1st one to test if it continue to work. Sure that is the way I will process if I need to test the 1st one. very interesting post. I8217m also testing the range of the black modules at this moment and at the beginning I had many problems with lost packages. This is solved now, but the maximum distance seems to be only about 5m, which is pretty sad8230 Any idea, what might be the problem Would it be possible, that you post the full code I just ordered four green versions and hope to get better results. I also have some modules with an external antenna. In the end I want to have one module with external antenna working as a receiver and four small modules in a range of 50m around it Thanks in advance Best regards Andreas Andreas, What is important is also the size of the payload and the speed. I was able to reach 50 meter with speed about 250kbps with a payload of 8 bytes. I Will post my test code size if you want, no problem. Charles we can use wire to increase range. Le message que je viens de post est une erreur li la vrification. Merci pour la reponse. Sinon pour les questions j8217utilise la library que tu as propos et pour le hardware j8217ai essay sur le uno et le mini pro, mais le problme doit venir de l8217ide(1.0.5 et 1.5.6), vue que lors de la verification j8217ai dj les messages d8217erreur. J8217ai essay les autres codes propos en exemples(de la mme library) et ils fonctionnent sans problme. Je pense que le problme viens de moi, j8217ai l8217impression que code n8217est pas fait pour tre juste copi coll, on est surement sens complter avec les paramtres basiques, comme dj inclure la library, nn. Je connaissais rien en programmation avant de commencer la semaine avec l8217arduino donc je suis un peut dpass sur ce coup. Ce type de module peu utiliser des intermdiaires. Par exemple, les esclaves(avec des nRF24L01 de courte distance) envoient des donns au matre et qui une fois regroup envoi un autre nRF24L01(de longue distance) beaucoup plus loin qui est reli a un raspberry par exemple et permet donc de lire les donnes sur un ordi de bureau. Avec la mme ide, c8217est possible d8217utiliser un module qu8217on planque a mi-chemin pour augmenter la distance Tu utilises la librairie que je propose mais laquelle. celle dans le repo pour Arduino ou celle du Rasberry. Parce que rien que pour celle du raspberry tu as 2 versions (nrf24-bcm) qui est la mienne et une autre de Stanley (je sais c8217est le bronx ce repo mais je l8217ai fork j8217ai pas eu la main sur sa structure). Oui le code doit tre modifi a minima pour le 8220pining8221 de comment est branch ton NRF24, les parametres de com doivent aussi tre les mmes de tous les cots pour que a fonctionne. Je te conseille dans un premier temps de faire fonctionner entre 2 arduinos (ou 2 raspberry) histoire que voir que tout est ok dj. ensuite passe un Arduino 1 Raspberry. Pour rpondre ta question, oui c8217est tout a fait possible de faire un 8220relais8221, je te conseille l8217article de manicbug. c8217est le crateur d8217origine de la librairie pour Arduino Hi Charles and thank you a lot due to your effort on running real life test for nordic RF modules. if you really want to experience the maximum range you should consider tips below: pages 58,59 from datasheet saying that: note that if 8220payload bytes are set more than 15 bytes8221 and 8220Speed set to 2Mbps8221 ARD(Auto Retransmition Delay) should be 500uS or more note that if 8220payload bytes are set more than 5 bytes8221 and 8220Speed set to 1Mbps8221 ARD(Auto Retransmition Delay) should be 500uS or more note that if 8220Speed set to 250Kbps8221 ARD(Auto Retransmition Delay) should be 500uS or more even when the payload is not in acknowledge mode That way you can take the advantage of long range with 250Kbps which is still very high speed. I hope this could be used as a small contribution in paving the way of Radio Frequency Projects. Hi Iman, thanks for the tip, it could help for sure. For my projects I now use RFM12B and RFM69 so there is a long time now I8217ve not played with NRF modules. Charles hi I am working on nrf24l01. I am using atmega32 controller on both side. I got data at receiver side but it take too much time receive. Plz help me to solve this problem. Hi Anny, have you first checked the status and config registers this is the first step. then you have to check whether the payload has the true data in receiver or not after that it might be a good idea to consider this important tip: 8220even when you8217re writing code for Transmitter, you should consider setting both RXADDR0 and TXADDR for it8221 but for receiver it8217s only sufficient to set the RXADDR0. RXADDR0 is and example of using pipe0 you can change it to RXADDRn which n can vary from 0 to 5 but both Transmitter amp Receiver should have the same ADDRESS(e. g 0x12 0x12 0x12 0x12 0x12 which are 5 bytes array pointed to ADDRESS) also my region of interest is here: 1)POWER ELECTRONICS 2)Image Processing 3)C Visual Studio Design 4)C and C embedded programming 5)PIC, dsPIC, AVR 6)Control Designs 7)Mathematics and Physics if you had any problem in the subjects above, I would be glad if I could help the only way you will get longer range is setting baud rate way lower8230 you need to go down to 9600 bps (maximum value), 1200 or even lower8230 with this baud rates you will get way more than 200-300 meters8230 (I used to get 150 mtrs easily with tucws 433 rxamptx at those baud rates) Hello Charles i have the black nrf24l01 module without the antenna on it and i did a range test line of sight i got 220 ft range i couldn8217t test no more because buildings was in the way i did a youtube video youtubewatchvT83wWl5V6lE indoors in my apartment i got 50 ft in one direction and 60 ft from the bedroom to the hallway through brick and doors but that8217s all i just did a pin test using a blink led to see the range of it. i just order the one with the external antenna and higher range from what i have seen they should do a better range test. i post a update when ready. Hi Joseph, Thank you very much for your head up. Excellent video by the way I appreciate your share there and your interest for these modules. I8217m excited to see your new tests. Charles I use the integrated antenna Black modules, and found that range was GREATLY effected by orientation (as with most RF products). I found the best range was obtained by orienting them so that the resonator was up and the - pins were bottom, AND that the copper face antennae from each module are facing each other. Test done with sending 1 Character, I get about 40m max through light garden bushes from my house window 1Mbps. I can8217t get my NRF24L01 to set to 250Kbps, would be great if anyone could help with that Hi Peter, Thank you for the tip, I8217m sure it will help some of us Are you sure you got one 82208221 version. Because 250KBPS are available only on these modules if I remember correctly. May be it could be why. If you want to learn what you can do with this puppy please visit: mysensors. org The MySensors Arduino library is easy to use and allows relaying of messages to increase the range of your sensors. During the last year the MySensors forum has gathered much valuable information on how to use the NRF24L01 optimally. Thanks for posting this information, very useful read. I have a question which has been mentioned before back 2013, but wondering if you have made any further tests in this area. I am interested in the approximate range if the Master is a PALNA module and the a Slave is a basic cheap PCB antenna module, then used in uni-directional mode with the ACKnowldge function turned off. If you have any ideas of approximate range (open air) I have some on order from China so will be making the tests myself but curious if this is something you have an idea on. Hi Ant, Thank for your comment. Well I8217m not using these modules anymore, I switched over RFM69 so I do not have test boards on hands. But as far as I remember I tested this configuration, and I obtained about 10 better range than with no PALNA. Seems close to the less performance module which makes sense. Of course both with PALNA was far better (and most expensive) I8217ve seen analyses that suggest that the noise floor is often the limiting factor for the nRF24L01 modules, and that the PALNA variation gains you very little in terms of reception, tho it does substantially increase transmission. (ie: The PA really helps transmission, but the LNA doesn8217t help reception much because it8217s more noise limited). However the external antenna (with or without PALNA) does give you some gain for both reception and transmission, at least when the target is closer to right angles with the axis of the external antenna (do NOT point the external antenna at the other unit, that8217s the worst direction). What this means: You get good advantage going from a PALNA unit to a plain (PCB antenna) unit, but much less improvement for sending from plan to PALNA. If you are sending with ACK (which makes it bidirectional) then the latter direction is your limiting factor 8211 either the main packet or the ACK is going to drop out first with increasing distance. And from PALNA to PALNA gets major range increase (taking advantage of the PA both ways, as well as the antennas). The other factor is the power supply 8211 most of the units from China are very sensitive to even small amounts of noise on the power supply. That can vary from no reception at all, to reduced range. A cap across the power supply leads helps. PIC18F2550 KS0108 Graphical LCD Oscilloscope Using the PIC18F2550 GLCD Text Test as a basis for further experimentation, I put together a simple and accurate graphical oscilloscope using a PIC18F2550 microcontroller and a AGM1264F graphical LCD. The oscilloscope measures the average voltage, the maximum voltage, the minimum voltage, the peak-to-peak voltage, and the zero-crossing frequency for a DC signal over 100 samples. The oscilloscope has a built in edge trigger function that can be set to capture on rise or fall (or disabled altogether). The time scale for the display is variable and can be easily redefined using the changeTimeDivision function. Likewise, the voltage range can be change to 0-5V, 0-2.5V, and 0-1.25V. The main limitations of this oscilloscope include relatively slow acquisition time and sampling rate ( 60kHz) and the fact that the inputs are limited by the constraints of the internal ADC. However, it is a very nice display and I highly suggest you view the videos to see it in action. The source and firmware for the circuit can be found at the bottom of the page. Each section of the circuit is labeled in the schematic. All of the sections and their components are described and discussed below. The part numbers for the components are linked to websites for data and more information when available. The power supply uses a 9 volt battery and a TC1262-5.0V high-accuracy low-dropout linear voltage regulator to provide a stable 5 volt supply for the microcontroller and the graphical LCD. A 1uF (microFarad) polarized decoupling capacitor is necessary on the output of the voltage regulator to prevent power spikes or ripples. A wall wart power supply as low as 5.3V can be substituted for the 9 Volt battery. AZ Displays AGM1264F The AGM1264F is 128 x 64 pixel graphical LCD with built in controllers that allow is to be easily controlled using a PIC microcontroller. It is a 128 x 64 pixel graphical LCD and has an LED backlight, onboard negative voltage generator (LMC7660) for LCD driving, onboard Samsung KS0108 controller, and an 8-Bit MPU interface. The 1st analog input (Pin A0) is configured to be an analog input. Please note that 8220The source impedance affects the offset voltage at the analog input (due to pin leakage current). The maximum recommended impedance for analog sources is 2.5 k.8221 (PIC18F2550, p.260) The microcontroller used is a Microchip PIC18F2550. I modified the PIC18F2550 Tiny PIC Bootloader assembly file so I could use a 20MHz crystalresonator at 115,200 baud (the modified bootloader can be found at the bottom of the page). The PIC18F2550 runs at 48MHz using the internal PLL. R1 is a pull-up resistor necessary for operation. C1 is a stabilizing capacitor that is used for the onboard USB voltage regulator, which is not used in this project. The component marked 8216RES8217 is a 20MHz resonator. RS232 Level Converter The microcontroller USART pins need to be connected to a RS-232 Level Converter to connect to a PC for firmware updates using the Tiny PIC Bootloader. Otherwise, after initial programming they can be left disconnected. Source and Firmware The PIC must initially programmed with the 8216SACtinybld18F2550usb 20MHz11520048MHz8217 hex file to program the bootloader on the PIC. Then, using Tiny PIC Bootloader, the hex file can be placed on the chip using the Tiny PIC Bootloader frontend with 821712h 34h 56h 78h 90h8217 in the 8216List of codes to send first:8217 in the 8216Options8217 menu. Please feel free to contact me if you have any problems. Videos Here are three videos of the PIC18F2550 GLCD Oscilloscope in action. The first video demonstrates sine, triangle, and square waves of different frequencies. The second video demonstrates different waves with shifting amplitudes and offsets. The third video compares the display of the PIC18F2550 GLCD Oscilloscope to the display of a Hewlett Packard 54603B oscilloscope. Update (November 15, 2006) Here is the firmware without the bootloader code: Update (February 1, 2007) Here is untested firmware for the PIC18F4550 without the bootloader code: Update (April 11, 2007) Here is untested firmware for the PIC18F252 and PIC18F452 without the bootloader code. Please note that you will need to use a 10MHz crystalresonator instead of a 20MHz one. Share this: Nicu 8211 An external AD converter would help increase the sampling rate. Right now the oscilloscope acts as a storage oscilloscope. I could greatly increase the speed and resolution of the oscilloscope if I used an external ADC. As for using it as a logic analyzer, to be honest I hadn8217t considered it. A logic analyzer would be very easy to put together with a PIC. The only issue that I could think of is whether or not the resolution of the LCD (12821564) is high enough for multiple channels. Mimmo 8211 For the firmware without bootloader, yep, all you need to do is program the PIC, make the necessary connections, and it will work Please note that this version of the firmware has a set resolution and update rate. I plan on building an oscilloscope with a rotary encoder and pushbutton to change settings. Thanks Steve, I cannot understand C, only assembler and PicBasiPro, so I am not able to modify your C firm to manage pushbuttons or a rotary encoder. I will wait your next relase, hi. I have all materials, so I can start to build it. It would be nice to use an external AD converter to increase performaces from a simple 8220logic analyzer8221 to a nice 8220oscilloscope8221 even if with only one channel. Congrats again. Ciao from Rome 8211 Italy How about using Microchip USB bootloader. I think that 12821564 pixels should be ok for Logic Analizer8230 or a bigger one could be used I also think it owuld be very nice to have the code available in BASIC or pseudo code. This way it could easily be ported to other uC8217s. I am more of an AVR guy :p Maybe even just a flow chart of the process If you ever do, it8217d be nice if you let me know I8217d really be interested Matthieu 8211 I haven8217t ported the code to BASIC or pseudo code, but that is definitely a future possibility The CCS C code should be ANSI C (although it includes a number of functions that are internally defined), so it should be possible to port it to an AVR (using avr-gcc). I8217ll keep updating and see what I can do Steve, for work with slow indicators, such as XIAMEN GDH12864A and similar, in standard functions of recording and reading in LCD () is necessary to add file GLCD. C a delay on 2 uS between distribution of the data and signal E (pin 6 LCDRC2) and also to increase on 2 uS duration of it . Otherwise the screen 8220collapses8221. Yours faithfully, Andrey. Moscow. Andrey 8211 Some displays are slower than others, so yes, it would be beneficial to use the delay. On my display (AGM1264F) the screen updates perfectly fine without it however, that does not mean that every KS0108 graphical LCD will. I have found that some HD44780 compatible drivers (text LCD drivers) have similar issues with signal processing speed, so you need to insert delays to ensure that there is no display corruption. Steve, Are you working on the new version of this little jewel I8217ve read you are planning to make an oscilloscope with buttons and rotary encoder to change setting. Do you think I can start to build this one and then update it with new firmware and wiring modifications as it will be available Are there any issue on 18f2550 programming Will a standard JDM programmer work with this pic Thanks Francesco Francesco 8211 Yes I am, but very slowly. I have been trying to complete human subject testing for one of my co-workers and it has taken much more time than either of us expected. It has been a long week (and weekend). My planned updates include: 1. Auto-ranging (both voltage and time domain) 2. 3 pushbutton for manually changing parameters 3. USB support, or at the very least USB bootloading If you can program the firmware initially then there should not be a problem in the future. Also, as long as the JDM programmer supports the PIC18F series (and specifically the PIC18F2550), then there will not be a problem. I checked online and found a couple of sites that say they support both the JDM programmer and the PIC18F2550 (members. aon. atelectronicspicpicpgmindex. html. qsldl4yhfwinpicpr. html ) though it seems like you might need to slightly modify the programming circuit. Please, can someone ported the originally code to 8220MikroC8221 or 8220MikroBasic8221 from Mikroelektronica Thanks Vincenzo 32 (GIOVANNI) 8211 This currently reads frequency using zero-crossing detection. It could potentially be modified with a DFT or FFT algorythm. 33 (Uncle Chris) 8211 Honestly, I8217m not sure, I should hook it up and see what the output looks like 34 (ScottM) 8211 The time delays are functions in CCS C. I8217ve verified (using a seperate oscilloscope) that the measurements are very close to the actual signal, but given that I am using an imprecise timebase (a 20MHz resonator), I can not presume that they are exact. 35 (Ahm1) 8211 Ask and you shall receive See the update at the bottom of the post, it includes compiled code for the PIC18F252 and PIC18F452: 18F252 GLCD Oscilloscope DR1r1 8211 no bootloader. c (hex) 18F452 GLCD Oscilloscope DR1r1 8211 no bootloader. c (hex) Hi, I8217m going to use the PIC18F4620, would that be ok I will ofcourse include the correct header file. Also the TC1264 voltage regulator has a max input voltage of 6v ( from the datasheet ) did you have any problems using a 9v battery. Great project Steve, I have been trying to get my 64128 to display a sine wave for ages and just don8217t have the know how. I am having difficulty trying to work out the process to plot the pixel points, too much math for me I think. I Need something that will work to 20kHz and your project looks spot on. Do you have a process or flow chart for how the sine wave display section works please 39 (Gordon) 8211 I dropped you an email about this, but I should post it as well. Unfortunately I don8217t have a process or flow chart however here is a basic rundown of what the Graphical LCD O-scope does: Samples all of the analog-to-digital converter (ADC) at a predefined rate and stores 100 samples in a RAM array. The discrete samples are then multiplied by a constant ratio so that they will fit on the screen. In other words, the samples are converted from a range of 0-255 to 0-63. The samples are then plotted one by one. I8217d be happy to help you out further if you have questions about it. The actual display of the sinusoidal waveform is a simple x-y plot. The sinusoidal wave is actually what a function generator is presenting to the ADC. pin of pic X input says: hi im using solomons graphic display 160128 dots 8230. it has toshiba t693c processor 8230. and i havnt programmed for graphic display yet 8230 i only used 2line alphanumeric 8230 so will u please help in providing the proceedure for initialising and displaying data in it . Hi Nice project. I need a little help becouse i8217m new to pics. With my display LGM12864B-NSW-BBS i can8217t geting to make to work. I don8217t understand the glcd. c and where to find it and how to implant in pic18F4550. Litlle help with the hex wil be realy good. Grazie. Zlatko I maneged to make it wotk but still have some strange problem, the menu (AV, MV 8230.) is in the middle of the screen han jian (china) says: You are good. you can consult such a conversion efficiency that CPU is SX28AC. AD is ADC08831. bandwidth is 5 Mhz. suppose AD substitute be ADC08231, bandwidth ought to can achieve 10Mhz. sx28s instruction is with PIC16C5Xs compatible SX code all the quickly job, taking advantage of the 50 MIPS. ADC08831 Resolution: 8 bits, Conversion time (fC 2 MHz): 4s (max), ADC08231 Resolution: 8 Bits, Conversion time (fC e 4 MHz) 2 ms (Max), efplustechrefscenixsxoscopeindex. htm han jian (china) says: ADC08231 Resolution: 8 Bits, Conversion time (fC 4 MHz) 2 us (Max), So here is what I got for MikroC for PIC16F877A. It compiles but give error of Not Enough RAM. Project name: GLCDoscope Copyright: LordSaibat Revision History: 20071104: 8211 initial release Description: This is a simple demonstration of the GLCD library routines: 8211 Init and Clear (pattern fill) 8211 Image display Test configuration: MCU: P16F877A Dev. Board: EasyPIC2EasyPic4 Oscillator: HS, 08.0000 MHz Ext. Modules: GLCD 12821564, KS108107 controller SW: mikroC v7.0.0.3 Notes: None. void displayFloat(int x, int y, float oldValue, float theValue) char toPrintOld4 char toPrint4 IntToStr(oldValue, toPrintOld ) toPrintOld2 8220f8221 IntToStr(theValue, toPrint) toPrint2 8220f8221 toPrintOld3 8221 toPrint3 8221 Limit shown digits to 3 GlcdWriteText(toPrintOld, x, y, 1) GlcdWriteText(toPrint, x, y, 1) void displayInt8(int x, int y, int oldValue, int theValue) char toPrintOld4 char toPrint4 IntToStr(oldValue, toPrintOld) toPrintOld2 8220u8221 IntToStr(theValue, toPrint) toPrint2 8220u8221 toPrintOld3 8221 toPrint3 8221 Limit shown digits to 3 GlcdWriteText(toPrintOld, x, y, 1) GlcdWriteText(toPrint, x, y, 1) void displayInt16(int x, int y, int oldValue, int theValue) char toPrintOld6 char toPrint6 IntToStr(oldValue, toPrintOld) toPrintOld4 8220lu8221 IntToStr (theValue, toPrint) toPrint4 8220lu8221 toPrintOld5 8221 toPrint5 8221 Limit shown digits to 5 GlcdWriteText(toPrintOld, x, y, 1) GlcdWriteText(toPrint, x, y, 1) int useThreshold 0 0 Off, 1 Rising, 2 Falling int theThreshold 127 int timeType 1 1 us, 2 ms int timePeriod 4 us or ms per measurement ( 25 for each div) int voltageRange 1 1 0 8211 5V, 2 0 8211 2.5V, 3 0 8211 1.25V float voltageConst 0.079365 For displaying the scaled voltage char strAverageV 8220Av8221 char strVMaximum 8220Mx8221 char strVMinimum 8220Mn8221 char strVPtoP 8220PP8221 char strThreshold 8221Th8221 char strOff 8220Off8221 char strRising 8220Rise8221 char strFalling 8220Fall8221 char strTime 8220Tm8221 char strMs 8220msdiv8221 char strHz 8220Hz8221 char strRange 8220R8221 char strR0to5 82200-58221 char strR0to25 82200-2.58221 char strR0to12 82200-1.28221 void changeThreshold(int theUsage, int theValue) float tempFloat 0.0 tempFloat (theThresholdgtgt2) voltageConst if (theUsage 0) GlcdWriteText(strOff, 12, 24, 1) else if (theUsage 1) GlcdWriteText(strRising, 12, 24, 1) displayFloat(12, 30, tempFloat, (theValuegtgt2) voltageConst) else if (theUsage 2) GlcdWriteText(strFalling, 12, 24, 1) displayFloat(12, 30, tempFloat, (theValuegtgt2) voltageConst) useThreshold theUsage theThreshold theValue GlcdWriteText(strThreshold, 0, 24, 1) if (useThreshold 0) GlcdWriteText(strOff, 12, 24, 1) else if (useThreshold 1) GlcdWriteText(strRising, 12, 24, 1) else if (useThreshold 2) GlcdWriteText(strFalling, 12, 24, 1) void changeTimeDivision(int theType, int theValue) float tempFloat 0.0, tempFloat2 0.0 GlcdWriteText(strTime, 0, 36, 1) if (theType 1) tempFloat timePeriod 25 tempFloat2 theValue 25 displayFloat(12, 36, tempFloat1000, tempFloat21000) else if (theType 2) displayFloat(12, 36, timePeriod 25, theValue 25) timeType theType timePeriod theValue if ((theType 1) ampamp (timePeriod tempThres) ampamp (ktempThres) ampamp (kgt4) else if (voltageRange 2) adcReadingsi 63-(HQadcReadingsigtgt3) else if (voltageRange 3) adcReadingsi 63-(HQadcReadingsigtgt2) Draw ADC readings for (i1 igt2))) ampamp (thres2(63-(theThresholdgtgt2))) ampamp (thres2(63-(theThresholdgtgt2))) ampamp (thres2gt2))) ampamp (thres2minV) minV adcReadingsi minV (float) (63-minV) voltageConst displayFloat(12, 12, minVOld, minV) minVOld minV Calculate and display Peak-to-peak V ptopV maxV 8211 minV displayFloat(12, 18, ptopVOld, ptopV) ptopVOld ptopV Display graph lines if (useThreshold 0) for (i29 igt2),1) for (i0 i Rujoi Laurentiu says: Steve, This is a great project8230 I had all the parts to hand, and built it in approx 3 hours one evening. It works really well8230I use it as a logic probe on my other pic projects. I8217m just working on building a case for it. Like many others who have looked at your code, I8217m a MikroBasic user, and would dearly love to have the source in that particular language. I have contemplated doing the conversion myself, so if I ever get around to it, I8217ll send it to you8230 I8217m looking forward to the mods you have in mind for it. Thanks again Can you please provide me the hex file which i have to burn on my PIC18F25508230 Please help me8230 hello, I need the initialising commands to configure a graphical LCD. i will b thankfull if u could post me the commands to my mail. also it will b very helpful if u culd specify the commands use also only needs the HEX codes. I8217am using CGM 064128f Graphical lcd with KS0713 Controller This is great project. I am currently working on a graphic LCD (for another project), that we get that in India for Rs.700 (US18). It has a resolution of 128X64 and I plan to make a CRO out of it. I also plan to use 18F4520, which has a sampling rate of 100KSpS (if I am correct). Will keep you posted, once I have some working model. I8217ve built this interesting little project and it works (all characters, numbers and the grid correctly displayed) but the waveform in not displayed, the line is at the bottom of the screen (as if there was a negative dc bias, that is not) and only the upper part of the sine wave is shown. I8217d be grateful for any suggestions to fix this thanks and regards Jorge Sancha says: Congratulations on the project, as I assembled and programmed the firmware but I funaciona correctly, I get disfigured texts and graphics and the set moved half of the screen, the display is the same you have on the link and the processor is a 18F2550. I think the problem is in synch, but my knowledge in programming limiados prevent me from resolving the problem. And these are very busy with your studies but agradeceria you explain that a little program and the bookstore that I pass the same thing, I think, that the companion Lagnajeet. The differences I have with your hardware is not available resonator me one and I put a glass with two ceramic capacitors of 15pf. If you are interested in the following link you can see a picture. Thank you for everything. Switch the CS1 and CS2 to the opposite RA3 and RA4 and it will fix the menu being in the middle Hi. I have changed the code a bit to get it working with the EasyPIC5 board, without success I have changed theese: The PLL to PLL2 (as i8217m running with a 8MHz Crystal) The GLCD Pins (running outputd and inputd, also the different pins are choosed cs1, cs2 and so on) It got compiled, and programmed fine. But when i run it, i only get many different dots, different places on the screen BUT.. If i change the Input Voltage, i can se that some dots are moving, either higher or lower, after what i8217m doing to the Input Voltage So it8217s working a little bit, but i can8217t see any text or anything, just strange dots on many different places I Hope you can help me out, i8217m using a PIC18F4550 with 8Mhz Crystal, and the pins like this: define GLCDCS1 PINB0 Chip Selection 1 define GLCDCS2 PINB1 Chip Selection 2 define GLCDDI PINB2 Data or Instruction input define GLCDRW PINB3 ReadWrite define GLCDE PINB4 Enable define GLCDRST PINB5 Reset hi, there8230.I managed to made all the connections as shown in the FULL Circuit and the HEX file without the bootloader was programmed into the PIC18F25508230Problem is the waveform does not shown appropriately on the screen and frequency always varied does not seems to be stable.. However, i need to adjust my function generator to 10Vp-p to show a proper waveform on my screen8230From 1vp-p to 5vp-p the waveform shown was just merely small dot of pixel8230. to anyone who might be interested, my personal version of the PIC18F2550 Scope can be found here along with voltage divider and input amp description: Regards and thanks Pingback: Osciloscpios com PIC - Eletrnica Brasil NICE WORK STEVE, BUT I HAVE A QUESTION. FROM GOING THROUGH YOUR CCS C CODE, I REALIZED THAT YOU CARRY OUT SAMPLING FOR 100 POINTS, WHICH WILL EFFECTIVELY FILL YOUR DISPLAY SIZE AND THEN YOU PLOT IT ON THE GLCD AND THEN DELAY FOR 100MS TO AVOID FLICKERING. MY QUESTION IS FOR A FAST CHANGING SIGNAL DON8217T YOU THINK YOU WILL LOOSE VALUABLE SAMPLES DURING THOSE PROCESSING TIME I AM SORRY IF MY QUESTION SOUNDS FOOLISH, I AM JUST SWEATING OUT AN OSCILLOSCOPE DESIGN HERE AND FIND OUT I HAVE DISCONTINUOUS WAVEFORM, BECAUSE OF THE TIME IT TAKES TO PROCESS AND PLOT THE DATA, THE FASTEST I CAN GO WITH MIKRO C PRO COMPILER IS 4ms TO PLOT ON THE GLCD AND THAT STILL SOUND A LOT FOR DATA LOST COS OF PROCESSING AND THEN DISPLAY, I HAVE BEEN TRYING TO SEE HOW CONVENTIONAL OSCILLOSCOPE DO REAL TIME DISPLAY, ANY LINK OR FURTHER INFORMATION WILL BE APPRECIATED. MY SIMPLE PROBLEM OR PUZZLE IS WHEN PROCESSING DATA AND CALCULATING ALL THOSE AVERAGE AND PEAK TO PEAK POINTS AND PLOTTING DATA ON GLCD, THE ADC DOES NOT TAKE ANY SAMPLE, AND THAT LOST SAMPLE LEADS TO WAVEFORM DISCONTINUITY FOR FAST CHANGING SIGNALS. SORRY FOR YOUR TIME AND THANKS IN ADVANCE, WILL BE GLAD IF ANY OTHER PERSON MORE KNOWLEDGEABLE THAN ME WILL CONTRIBUTE. JUST LEARNING I am a student and i tried to study your code but i cannot compile the code using MikroC C compiler. Can i know what step i need to do in-order for me to compile the source code I have made Proteus design and ran the simulation for PIC18F2550 ( no bootloader) If i use the ADC DIV64 i get ADC conversion error ( the speed of the PIC in protheus is set to 20Mhz. if i use 48 Mhz i get errors Logic connections detected and the RB4 port flashes yellow ( LCD shows nothing). What i did to get it partly workingis is the following : 1)PIC18F2550F in Protheus is set to 20Mhz and using a 20Mhz quartz . 2)the code in CCS uses the delay of 48 000 000 Hz ( as it is in the original file ) . The only thing i change in the. c file is the SETUPADC(ADCCLOCKDIV32) If i leave it as it is originally SETUPADC(ADCCLOCKDIV64) i get this error. PC0x1B6C. ADC conversion started before 8216wait8217 time has expired following previous conversion or channel change. THE ONLY problem i get is that when i connect a VFSM sine wave generator to RA0 i get only the positive part of the sine wave on the screen . Also it seems for me that CS2 must be connected to RA3 and CS1 to RA4 Please let me know what i am missing A Banerjee says: If u r using a cheap JHD12864e GLCD, u might also need to change the delay functions in GLCD-modified. c to 50us. JHD is a slow GLCD. With the default 2us delay, it wont work and show only a few dots as seen by Thomas J. For those of you only seeing the top half of the waveform: Input to the PIC is from 0 to 5V (maximum). In other words, if you try to feed it a signal centered around zero you will lose the negative-going half and just display the positive half. The way to get round this is to add 2.5v DC bias to the input then AC couple the input signal through a capacitor. The bias will move the display upwards so that the 8220zero8221 is now half way up the display. Your input range is now 2.5v peak to peak but you have lost the DC input capability. It8217s possible to sort this out too, but your input op-amp will need a negative supply. hi, can someone help me plz i want to print my data on GLCD that be similar to following picture.(texts are inverted) i use ccs compiler and pic 16f series. thanks a lot. hi, I8217m using pic18f4550 and WG12864 lcd. works well up to 300hz. should it auto-scale on x (time) axis does anyone have the same problem anyway, nice project thanks Daniel Jimenez says: I want work with microsec. What parameters i need puts into the ChangeTimeDivision function. Hello Steve, I would try to build an oscilloscope with pic 18f2550, but it would be possible to program the pic hex file directly with the bootloader without using my programmer many thanks Sergio Hello Steve, I would try to build an oscilloscope with pic 18f2550, but it would be possible to program the pic hex file directly without the bootloader using my programmer Many Thanks Sergio P. S. I8217m sorry there was an english mistake in the previous post. Best regards hello could someone give me the simulation in Proteus plis because I try a lot and I cant make it :C

No comments:

Post a Comment