NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Who's up for a community project? Let's build something!

February 22, 2012
by 4bits4e4
4bits4e4's Avatar

Calling ALL programmers for a Nerdkit community project bringing the sharpest minds together for the benefit of those enthusiasts wanting to explore uC programming and implementation using a NerdKit. A project using just the Nerdkit components,teaching the rudiments of program structure (looping, pointers, keypad scan, LCD, etc). My suggestion would be a simple interactive trainer with an interpreted language of 16 opcodes and 16 functions, all of which can be changed and a few that can be written using the trainer. I envision a menu driven operating system scanning 6 keypad switches and functions designed to manipulate the display. Capability of writing simple programs and editing memory. A fictional uC with a customizable instruction set. A project that gives participants and followers a resource to explore several of the 168's capabilities and a valuable development tool that is expandable and adaptable to tier 2 projects etc. Sounds like something I would want to be a part of, how bout you?

February 22, 2012
by hevans
(NerdKits Staff)

hevans's Avatar

Hi 4bits4e4,

This sounds like an awesome idea. Not only would something like this get people working together, it sounds like it would be a fantastic learning platform.

Humberto

February 22, 2012
by 4bits4e4
4bits4e4's Avatar

Personally I have to agree that it is an awesome idea! I have done a similar project using an Atmel 8052 so I can tell you, by the time you have a working system, there are very few aspects of the uC that haven't been explored and or implemented. The code will be generously commented with a depth of explanation geared toward a beginner. The end product becomes a fun and educational gadget that you can share with friends and maybe even get them into the community. The project teaches memory management, addressing modes, looping and branching, interfacing, pointers, tables, while promoting creativity and thinking, thinking, thinking. The operating system includes a single step debugging mode that allows them to watch their code run and see the registers and memory changing value. From the main menu they can choose to Edit or Run a program, Edit memory or build a screen on the LCD. Some beeps and boops from the piezo speaker, a pocket sized quick ref card, and you have audio visual learning tool that is easy and fun to learn without having to carry a backpack full of documentation. Initially the project will need some creative and sharp minds to discuss and brain storm on how to achieve the best learning tool for a beginner. The stock instruction set will be specially selected to teach programming while they create chasers and a game of slalom or "pong" on the display. Once they have a good understanding of structured programming they can learn about the compiler and begin writing their own instructions and make the gadget into a customized dedicated widget without the burden of development from scratch. There's nothing quite like a cooperative programming project when your goal is to learn and have a good time doing it! Sign up! Let's build something!

February 23, 2012
by 4bits4e4
4bits4e4's Avatar

Doing some layout, filling in the blanks. Feel free to comment or contribute.

// 4bit Trainer using Atmel 168 and the NerdKit bootloader.
// Conception Date 1/29/12
// by 4bits4E4
#include mod4bit    // Define virtual machine resources
#include nerkitlib  // Various libraries used by Nerdkit Compiler
//
//Definitions (examples)
//URMODE    Byte    //User Run Mode 
//URSPD     Byte    //0=step, 1-E = delay, F=no delay
//EOFLG     BIT     //EOF Flag for user defined functions
//Port1     Byte    //LCD Port
//USP       Byte    //User Stack Pointer
//UDPL      Byte    //User Data Pointer Low nybble
//UDPH      Byte    //User Data Pointer High
//WMCON     Bit     // Memory Control Register
//RSTFLG    Bit     //Reset Flag Soft
//GOFLG     Bit     //GO Flag
//VRFLG     Bit     //View Registers FLAG
//UPSW      Byte    //User Program Status Word
//MENUK     Bit     //Menu Key Flag
//MDP       Word    //Monitor Data Pointer
//VUDP      Word    //Virtual User Data Pointer
//VUAR      Byte    //Virtual User A register 4bit
//VUBR      Byte    //Virtual User B Register 4bit
//VUCR      Byte    //Virtual User C Register 4bit
//VUYR      Byte    //Virtual User Y register 8bit
//VUZR      Byte    //Virtual User Z register 8bit
//UJPL      Byte    //User Jump address Low nybble 8bit
//UJPH      Byte    //User Jump address High nybble 8bit
//UPC       Word    //User program counter 16bits

//************************************************************
// Softreset function. Maybe hardwired!
//org 00        //TBD for interrupt usage

//**************************************************************
//
// Init routine
//Set and Enable Interrupt vectors
//Enable EEPROM writes
//Read monitor startup parameters.
//
//****************************************************************
//
// Keypad polling triggered by timer interrupt
//
// 3x3 matrix. 5keys, 4 user inputs. 
//(UP, Down, Left, Right. Select.)
//Menu key is pin change interrupt?
//
//***************************************************************
//
//Keypress
//  Debounce
//Keypress
//Parse
//  Gotkey
//Lastkey store
//
//******************************************************************
//
//Set Address for User program counter/Data Pointer 16bits
// UADL UADH = RamArray(x,x,x,x)
//
//******************************************************************
//
//Run mode menu
//URmode = RamArray(x)
//URSPD = RamArray(x)
//0=step
//1-E = throttle
//F=full speed
//
//****************************************************************
//
//VIEW EEPROM Memory
//
//VIEW RAM
//
//****************************************************************
//
//Screen Builder
//--------------------  //20x12 RAM array (240 chars/screen)
//
//******************************************************************
//
//EEPROM WRITE
//
********************************************************************
//
//Edit/View Program
//
//  Disassembler
//
//      Fetch opcode=UPC
//      Fetch neumonic=(lookup table)
//      Fetch data=UPC
//
//EEPROM Write
//
//*************************************************************
//
//Debug/Single step run mode
//
//Fetch User regs (A,B,C,Y,Z,DP,PC)
//VUAR,VUBR,VUCR,VUYR,VUZR,VUDP,UPC
//
//Build Screen (RAM)
//
//Display
//
//********************************************************************
//
//4bit Instruction Set (Examples)

//Mov A,#       A<immed 4bit
//Add A,#       A<A+ immed 4bit
//Cmp A,#       A?= immed 4bit, flag=Z
//And A,#       A< AND immed 4bit, flag=Z
//Or  A,#       A< Or immed 4bit
//Sfr A,#       A>> immed 4bit Shift right flag=Carry, Zero
//M(DP+Y),A     Store A @ Mem(ptr+offset), Indirect indexed
//A,M(DP+Y)     A< Mem(ptr+offset), 
//Add A,B       A< A+B, Flag=Carry
//Mov Y,##      Y< immed 8bit, Indexing ptr
//Add Y,##      Y< Y + immed 8bit
//Cmp Y,##      Y?= immed 8bit
//Mov DP,###    DP< immed 12bit
//Inc DP        DP<DP+1
//Call #        Call 1 of sixteen functions Z=1?
//JP,###        Jump absolute, 12bit
//
//******************************************************************
//
//4bit Functions (examples, )
//
//Rstb,(DP+Y)   Reset bit @ Mem(DP+Y)
//Setb,(DP+Y)   Set bit @ Mem(DP+Y)
//P0,A          Port0 < Areg (control lines)
//P1,M(DP+Y)    Port1 < Mem(DP+Y)   Port1=LCD data lines
//Inc Y         Y< Y+1
//A,Key         A < Key value (1,2,4,8) Keypad Input
//Push          Regs to User Stack
//Pop           Regs from User Stack
//Xch A,B       Swap A and B regs
//Xch A,C       Swap A and C regs
//Xch Y,Z       Swap Y and Z regs
//Snd,A         Call sound routine 1-16
//Dly,B         Call delay, pass parameter=Breg
//Disp,B        Call Display function 1-16
//Ufunc         User Defined Function (set vector)
//Ufunc         User Defined Function (set Vector)
//******************************************************************
//  
//LCD Function calls
//
//Cursor on
//Cursor Off
//Cursor Blink
//Cursor Blink Off
//Cursor Home
//Clear Display
//Display off
//Display on
//Splash1
//Splash2
//
//
//
//******************************************************************
//

//
February 26, 2012
by 4bits4e4
4bits4e4's Avatar

Zero Response! Looking for an enhancement to the startup of the Nerdkit for beginners. Without a curriculum for newcomers the community risks withering on the vine. Think back when you were just getting started, what areas gave you the most trouble? How could your learning experience have been made easier? Let's list those things!

I've read several posts, from near zero knowledge members, I can identify with their being overwhelmed with all that needs to be learned to simply exercise a uC. Unfortunately, most of these beginners give up and the community has lost an opportunity to expand.

I think a project addressing would be a great way to give back to the Nerdkit guys for all their efforts thus far.

February 26, 2012
by Rick_S
Rick_S's Avatar

Ok, I'll bite. What exactly are you trying to do. It sounds as if you are trying to make some sort of interpreted language for the microcontroller to somewhat dumb down the amount of programming required to make things such as serial communications, LCD interraction, etc... easier to do.

Why??

The whole purpose of the way things are done is to learn by doing. If someone has a dumbed down version, they are not learning the in's and outs of what makes it tick. There are already basic libraries provided for communicating to the LCD, through the UART, and simple delay functions. Instructions are provided in the manual that if followed, work.

If simple was the intent, why not go arduino?? Plug and play. Lots of pre-built libraries, lots of open code, lots of examples, and next to no knowledge of what you are doing required.

Instead, with learn as you go, you develop the skills required to build something ground level up. Sure you may stumble a bit along the way. However, step by step, you build and grow.

That is what I see as the two different schools of thought. One starts kids out with training wheels - the other without. I was a learn w/o person myself. Those that learn with, either keep their training wheels on, or have to learn the hard way eventually, if they want to grow.

Maybe I have totally misunderstood what you are going for, but that was how it came across to me.

Rick

February 26, 2012
by dvdsnyd
dvdsnyd's Avatar

Hi, I believe I read into this project exactly as Rick did...

I am VERY new to microcontrollers and electronics in general. However I did A LOT of research for microcontroller programming and learning tutorials and kits to get started. Looking at things like the Basic Stamp kit, the Nerdkit, and an Arduino. I chose a Nerdkit because I believed it's statement about invest in yourself by learning as you do. Plus, I think it is the perfect "curriculum for beginners". The NK takes care of what I believe is the highest and most difficult hurdle to getting into embedded programming- finding a suitable chip out of the bazillions out there and getting a useful program onto the chip with one of the bajillion ways to program a chip(I know, I exaggerated a bit ;-) ) But I think you get what I mean. It gives you 1 chip and a simple way to program it. as well as a guide to get you started. The rest is really on you to go forward with the more complex system/design that you wanted to build initially, but didn't know where to start until you got the resources to do so(NK and guide).

After completing the guide, I just recently was able to take an accelerometer and connect it to the MCU and as I can tell it is functioning correctly. I was able to utilize these forums, the internet and the tempsensor project as a guide. I believe someone else can do exactly the same, as long as they take the steps to do so.

It is HARD to get over some of the initial stumbles of programming and figuring out which register and which bit to turn high or low to get a desirable result from the MCU. However, I don't know how many times the Nerdkit guide refers to "take a look at the datasheet" (would be interesting to count it up) Because I know it is in there a lot. Heck, the 300 page pdf that is the datasheet for the 168 is DAUNTING in the least. It took me a while to actually dig in and see what they were talking about...and that brings up my only small thing that I would like to see implemented in the NK guide-more direct references to the datasheet. Get people really use to looking at it before setting them off on their own. I think it would have helped if it was said in a step...ok, go to page 134 and look at so and so, this is the bit we are setting and why...I know there are a couple of references almost like that, but more is always helpful. But, I digress- They(The NK crew/goal) want the consumer/learner/newbie... to learn by doing; using their bare bones LEARNING kit. Anyways, it is exactly those stumbles and figuring out what you did wrong where true learning takes place.

I think something like what you are describing, unless I am TOTALLY misunderstanding, in which I do apologize, would deter from people actually learning; or at the very least someone would plateau in their learning progression. If I learn C programming I can then maybe learn to put a boot loader on a different Atmel chip and go from there. Where can you go after you are done with your widget with an interpreted language?

Just seems to me that the end project is essentially a limited Arduino...?? Again, I apologize if I have offended you or anyone, but it is just how I see this particular project. I realize I basically stated what Rick said in rambled form, but felt it was necessary to add my own two cents.

David

February 27, 2012
by Rick_S
Rick_S's Avatar

@4bits4e4

I hope we didn't scare you off. I was hoping you would come back to discuss further.

Rick

February 27, 2012
by Ralphxyz
Ralphxyz's Avatar

bretm (who I really miss) did a whole simplified programing language.

Ralph

February 28, 2012
by 4bits4e4
4bits4e4's Avatar

This whole thread began with the suggestion of a community project. I put forth 1 idea I thought would be fun and useful. No other ideas came from the post. No comments on the idea of community involvement. What I got was more of a lashing for an unpopular idea and censure for my approach to particpating in the ND project.

Creating something new under the sun was not the intention. It was more to give this forum a friendly hello and propose cooperation in this learning environment.

I am impressed with the knowledge of several of the participants here and have gleaned valuable tidbits amongst the fractured pieces of information available here. Having been a teacher in electronics and computer programming I suppose it was presumptuous of me to propose structuring an area of the forum for the less knowledgable to find the arrow labled "START HERE".

I'll remain a member and work my kit. There will be no more bad ideas.

February 28, 2012
by SpaceGhost
SpaceGhost's Avatar

I certainly would not call your idea a "bad idea." I would not call any of anyone here's ideas, bad. I've seen ideas posted here that received little or no initial reaction - until another person later on became interested. Old threads that came back to life, etc. Your project may appeal to someone, somewhere, down the line. It happens.

I can relate a lot to what dvdsnyd posted above. I still consider myself a rank amateur, but I have learned a LOT compared to what I knew several months ago. And the learning process continues, at my own pace, acquiring new and supplementing old knowledge as I go along.

Like dvdsnyd, I wanted to get into micro controllers. Ah, then the question became which route to take - Arduino seemed too easy and at the same time too constraining, imo.

The Nerdkit platform seemed perfect. Start simple, get a grasp of what you are actually doing, then build from there. I came to the forum asking for help on how to build a relatively simple counter. I've coded and modified dozens of projects now from that counter. Blinking lights - an all important concept for first timers. What are you trying to do? Well, blink a LED. Then you realize there is much more thought that then goes into that - how long is is on? How long is it off? How do you adjust these rates?

The Nerdkits forums forces people to ask questions - sometimes you get an answer, sometimes you don't. If you are serious about getting an answer, you learn how to ask the question. Ya gotta show that you're seriously trying to figure something out. It really is neat how this thing seems to have worked out that way - it's like an unwritten rule that everyone seems to just naturally follow.

There are, and have been, some serious brainiacs here in this group. Some have stuck around, others seem to move on. New ones come along too. Not going to name names, but I've seen posts from one newer guy that shows he's an up and comer.

I wish I contributed more to these forums more often. I'm a bit of a lurker though, and I'm still slowly building on my own knowledge. I know just enough to keep myself fairly entertained, but then I'll get an idea for something that forces me to learn a little more. Gotta love that!

The Library (fairly recent addition), the posts and threads, and peoples questions and comments all contribute to the learning resources that are available here. Sometimes ya gotta dig for what you are looking for though. Sometimes you gotta use your imagination with the information you do find. Creative thinking - such as "hmmm, with what I read the other day, and what I learned studying someone elses project... I think I can turn that thermometer into a keypad controller!" Who'da thunk it?

So don't give up on us, and don't think your that your idea was bad or dumb, or that everyone hated it. You being a teacher, I'll bet that you will have a lot to contribute. Just be aware that most of us here are probably not your "average" type of students. I think you should fit in here pretty well!

Dave

February 28, 2012
by Rick_S
Rick_S's Avatar

4bits4e4,

I apologize if what I said came off as a lashing and censure of your idea. I made the assumption that you would come back, clarify if I misunderstood, and discuss it more. I am far from the singular voice of the forum. My opinions, while maybe a bit strong at times, are just that... my opinions. I meant NO disrespect to you. Don't let your idea die this easily... I'm sure there are those that would be interested. They may just be too nervous to respond.

Like Dave just said, you'll fit in fine and I'm sure, based on the work you said you did with the 8052, you'll have a lot to offer. Please don't be gun shy with ideas. Trust me, I've been shot down or ignored with some of my ideas before. :)

Rick

February 29, 2012
by 4bits4e4
4bits4e4's Avatar

Re reading the title of this post and my attempt to explain its purpose leaves me wondering why it hasn't been addressed. If there is no desire here, for a community project, let that be said.

Rick, I've read several of your posts and I see you as a promising hexhead that's good at flipping bits. You've helped others here and guided them in seeing their vision to fruition. Every project needs a critique to keep the creative juices flowing and the best ones have a suggestion to accompany any negative input. Why you chose to bash my suggested project isn't important. Let's hope you haven't damaged your reputation, among newcomers, as a valued member of the forum.

Dave, Don't be concerned about my feelings, re-read your two posts as a casual observer with emphasis on summarizing the intent. These words will remain on the web for years to come, be mindful of your messages and the emotions they contain.

Ralph, I have read several of your posts as well. I tip my hat to you my friend! You have a great imagination and an entreprenurial zeal. If the idea of a community project here gains momentum, I want to nominate you as the lead. Your friendly approach to guiding participants and newcomers to pertinent and helpful information is invaluable.

Let's end this thread on a positive note and get back to why we are here. Let's build something!

February 29, 2012
by Rick_S
Rick_S's Avatar

I think you really read into my post something that wasn't really intended. When I asked Why?? I was sincere. I really don't understand the reasoning behind something like this and assumed you would come back and explain. Instead, I got the silent treatment and you took it personally.

In my statements referring to the method of learning here, I was just reflecting the reasoning behind a method that has been proposed here since I joined. A method I believe has been here since the inception of the community.

That method is, as the home page of the website states:

Invest in yourself: learn by doing.

Then a couple of paragraphs later states:

A NerdKits microcontroller kit is appropriate for software hackers looking to branch out into electronics, and has educational material to allow even middle-schoolers and high-schoolers (ages 12+) looking for a fun challenge to learn by doing, especially with the help of a techie parent!

Now, I'll put all that mish-mash aside and state something else about your thought. While I do disagree with this project as a means to provide a simplified OS persay to beginners, I totally agree that a project like this could be VERY INTERESTING, in that members could develop a large group of libraries/includes that could help the developers of the project expand their horizons outside their own personal projects and comfort zones.

These libraries could be documented and kept in the NerdKit Library section and could be used by beginners to get some of their ideas and projects going without having to search the web for hours/days. Plus being that it was developed here, they could ask questions and hopefully get answers from the community.

I've tried to help along that line as have others here in the past. When I develop something I think might be of use, I post the code and do a simple write-up. This could be a Very large scale of that. It could also get some of the newer members that may have good programming skills doing more developing.

I am interested in keeping this going if you are, I just don't know where you want to go with this.

On a last note, if you are still reading:

My name is Rick, I am a 46yr old enthusiast who is completely self taught other than 1 semester in electronics at DeVry University back in 1984. I don't know that I would consider myself a promising hexhead that's good at flipping bits or not, but I do consider myself a slightly advanced beginner. As to whether this conversation will effect my reputation here, I doubt that. Most people who have been here any length of time know me, know I have helped countless beginners here, and my posts are witness of that. I apologize for my words that rubbed you wrong... I have bad tendancies that way. (Just ask my wife Wink )

I don't want to be anyone's rival here. I have tried to my best ability to explain my side and thoughts to your idea, I'm still interested in your feedback to that. Do you have a link to the 8052 project you were part of to give a better representation of what you are wanting to do??

Cheers

Rick

February 29, 2012
by 4bits4e4
4bits4e4's Avatar

Rick, Here is the title of the post: Who's up for a community project? Let's build something!

Here is the subject of the post. Calling ALL programmers for a Nerdkit community project bringing the sharpest minds together for the benefit of those enthusiasts wanting to explore uC programming and implementation using a NerdKit. A project using just the Nerdkit components,teaching the rudiments of program structure (looping, pointers, keypad scan, LCD, etc).

Here is an example of an enthusiastic response: This sounds like an awesome idea. Not only would something like this get people working together, it sounds like it would be a fantastic learning platform.

Here's some of what you have had to say: Ok, I'll bite.... What exactly are you trying to do.... dumb down the amount of programming required... Why??... the way things are done... dumbed down...not learning... go arduino... no knowledge of what you are doing required... I have totally misunderstood what you are going for...

Please re-read the outline of the proposed project with a positive view of its value. I will be happy to clear up any doubts you may have on the validity of this being a real project with real potential to learn from it. If this project does not interest you, don't participate, your negative input will have little or no value. If you have an opinion to share, please think positive.

I am moving on to another project idea that, if successful, will "teach" the rudiments of microcode. Microcode is the hardware program inside the micro controller. The marching of bits across a silicon substrate comprised of channels and gates designed to parse the binary language into logical and predictable workflow. I doubt seriously that this would interest someone struggling with blinking an LED.

February 29, 2012
by Rick_S
Rick_S's Avatar

When I said OK, I'll bite. I meant NO disrespect to you, I had seen you make multiple posts some quite large over several days. Since no-one else, other than Humberto (one of the owners) had responded, I opened with that line, like a fish taking bait.

Yes, I did say all the things you pointed out as well. I was thinking outloud and I could see how you might get upset if you saw these as personal jabs at you... which they weren't intended to be.

I visit this forum multiple times daily. Normally my first visit is between 4 and 5 am. So believe me I did read your outline, title, and opening. I am still waiting for an explanation of how exactly this benefits a new user or what the purpose of it is (other than a community project). You state that it will be a simple interactive trainer with an interpreted language of 16 opcodes and 16 functions, all of which can be changed and a few that can be written using the trainer.

I really must not understand what you are trying to achieve. It almost sounds like you are trying to turn the microcontroller into some form of PLC or simple I/O device on the surface while all the main programming behind the scene is transparent to the end user.

  1. Am I correct about that?

  2. Where do you want to take it and to what end?

  3. In you opinion, what benefit to the end user will it serve?

I will admit, I most likely come from a different background and probably have different methods of learning than you. It seems somewhat apparant. My main career is programming computer controlled machine tools (the ones that machine metals). And while I did teach for three years, it was to adults who wanted to become either a journeyman machinist or millwright.

I have re-jouvinated my childhood love of electronics over the past few years. I am a self motivated learner. I don't need much instruction, but when I do, I'm not afraid to ask. I never tell anyone my input is the end all be all, because almost all the time there is a better way. I encourage people to try to do the work for themselves and if they have questions ask. I'm not afraid to ask questions, or answer them if I can.

You obviously have a love for technical jargon and want to get deep into microcontrollers. Great! I don't know how much the average micro-controller programmer worries about all that but I won't attempt to speak for them. I do agree with you when you stated that you doubt seriously that this would interest someone struggling with blinking an LED.

If you are a fluent programmer, you will see that my C programmins skills suck. I won't apologise for that, I am fully aware and am still learning. Up until I began with microcontrollers, I hadn't written much at all in C so I'm still learning.

If you do decide to hang around this forum for a while, you will see that this is one of the few forums that seems to be, for the most part, friendly. As a matter of fact, I think this topic is the most heated I've ever seen here and it's pretty mild compared to some I've seen on other forums. There hasn't even been any name calling, unless you labeling me as a promising hexhead that's good at flipping bits a name. I don't even know how good of a bit flipper I am. LOL

BTW, what age students do you teach? Middle school, high school? My son had an electronics class in high school that was supposed to get into microcontrollers by the end of the second semester, but never reached that. They covered a lot of basics with passive components and focused a lot on digital IC's. Do you have a good curriculum for microcontroller programming in your school system? I had really wished the school system where I live had spent a little less time on the building of the digital circuits and a little more moving toward microcontrollers.

Here's to hoping the discussions can cool down. I don't want to start anything here and did not intend to incite you with my words. I would like you to clarify what your original intent was precisely. Like I said, maybe I misunderstood and this whole mess could have been avoided.

Rick

February 29, 2012
by 4bits4e4
4bits4e4's Avatar

Rick, Let me start by saying I like who you have described yourself as. Hexhead is a term of endearment and is a notch above Nerd, a title reserved for those with more than a casual commitment to thier programming obsessions (flipping bits). I harbor no animosity toward you for your ostensibly harsh critique of my first suggestion for a community project.

Let me introduce myself: I have been programming everything digital for 30+ years. I have 13 years of formal education in business and technology. A great deal of code, the fruits of my labor, now circle the Earth in the vaccuum of space. Most are now trash just waiting their turn to burn up on re-entry. When you see a satellite photo in a weather report, I helped. When you think of the extensive overhead electronic protection network of this country, I helped there too. I taught graduate level courses at two universities in Southern California for a period of about 6 years. I received my moniker 4bits when I spent a weeks wage to obtain my first integrated processor, the Intel 4004. I can program using several languages, machine and high level and, most of those are also now trash. C is not my strong suit and I don't believe C++ should exist at all when speaking of embedded languages.

The Nerdkit forum is not my only involvment with online development so, the pause in my post here was not the silent treatment, just busy elsewhere. I visited this forum several times, before deciding to join, looking for a group that would be open to the idea of working together and having a good time. In retrospect, "calling ALL programmers" was not a good example of my mannerisms. If you are truly interested in the learning platform project, I will try to do better at explaining why I chose that approach.

What is more important to me is the community project idea. There is nothing more enticing to a novice programmer than a friendly group of seemingly genius cutups who don't take themselves so serious as to be offended when they are the joke.

My microcode project is bound to be boring and dry. It will have little value to those looking for code to cut and paste during thier exploration of this excellent hobby. Mt parting words for now?

Let's Build Something!!

February 29, 2012
by Rick_S
Rick_S's Avatar

Wow, you definitely have the credentials! As for the project, I'm still trying to get my head around exactly what it's all about. I could see libraries that are fully written and documented being of benefit. I just don't quite get what you are wanting to do with the project you are outlining. Maybe I'm a bit dense :)

I'm sure a project like this could lead to a lot of learning with everyone involved. I really don't know how much help I could be though... It seems a bit beyond where I am. I love a challange but don't want to hold something up due to my lack of ability.

Rick

February 29, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

BRAVO...BRAVO...

I got my Nerdkit in April of 2009. I picked out the projects that I could make something light up or scroll. One short year later I was at the end of 'my road' so to speak.

Nerkits mostly taught me how a computer runs, how individual every program is. I took a shot at adding to code, I got the scroll to work where I wanted, and one day I had a piece of code that would not compile because of an 'indent error' say what! that was the real end.

Nerdkits is a platform for learning how to write code, and Billy was a billionaire before I bought my first comp, so no learning 'a' language for this guy. But if you want to write me some code, don't charge me a leg and I can stay the copy paste guy.

Running pipes on the Array are my forte, right now I wouldn't mind a email notifier. I haven't been around for awhile, I'll tell you what, I'll build it, 'The Eternal Life Array' one of you write the code. :)

February 29, 2012
by 4bits4e4
4bits4e4's Avatar

I'll try to highlight what I think is special about this type of project. It is an operating system complete with BIOS (Basic Input Output System). It is a monitor for the hardware allowing near total access to the available resources in the chips design. This is a RISC chip (Reduced Instruction Set Computer), so the instruction set is closer to the microcode than in a CISC (Complex Instruction Set Computer). I believe with this architecture, and some really tight code, we can put together a development platform that programers at any experience level can benefit from.

My experience with the 4bit52 (the 8052 project) allowed me to code custom functions on the fly using custom instructions. I quickly became proficient at creating complex instructions for the purpose of creating more complex functions to perform whatever 8 bits can do in the real world. All while sitting under a shade tree in the park. No need to hook up to the computer and recompile for each idea, only proven code enhancements would I bother with implementing into the operating system. Code I wrote using instructions I wrote calling functions I wrote. The "4bit" Nerdkit becomes a stand alone, portable Rapid Prototyping Platform that fits into a shiny gold cigarette case.

It is really quite a simple framework to create a virtual processor. It is the open development of the instruction set that will continue to challenge your creativity and allow you to build one idea on top of another without the burden of starting from scratch. Simulators, emulators, new microcontroller designs, you name it, they are done using an approach just like this.

Enthusiasm and a willingness to learn is the only prerequisite for participating in the project. Once the BIOS and monitor are complete, we can each build our own custom instruction set if we so desire. You're never locked into a dead end processor because you can always write new instructions that will do exactly what your vison requires. These instructions and functions can be one liners or one page. It's your talent, so it should be your processor!

February 29, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

In Rick's famous words, Ok, I'll bite.

They did some monitor stuff here but really never got to running a program with a monitor like the one im writing on. Being it's own identity, you'll need a keyboard too, yes? If this is what you mean, im in.

fjc alias Grant from Canada.

March 01, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

On second thought...I should give up now, while im still sane. I can't get my Whale Tail, heart code combo to work...AND...

I see you guy's or some of you have Avatars, I went through the whole process, even added another email and nothing. One of the images on that stupid avatar site is from facebook since I added my other email. Now thinking I'll go make it default and see. It seems that site is a joke, sorry if I offended anyone. url>>https://en.gravatar.com/emails

March 01, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

No I'm not trying to steel this thread, but...

Good Thursday mornin to ya.

I got one for Rick's amusement. Two short vids of my Whale Tail, when it worked. I spent another couple hours on it and I got the display working but the code seems to be broken for the lights. No clue why, but maybe next winter, baseball is back on.

Link-1 http://www.youtube.com/watch?v=jgUCoN9IY3g&feature=youtu.be Link-2 http://www.youtube.com/watch?v=-kMKh992urA

ps. as you can see still no Avitar. :|

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

The project includes a 3x3 matrix keypad. The OS will initially use six of these and the remaining three become available for additional buttons or outside world inputs. There are also 5 unused port pins available for IO. After the initial project is up and running, it will easily port to the 169 64 pin package and offer much more IO capability while running off a cell phone battery.

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

Farmerjoe, Your avatar is visible to the forum. I see your protoboard. Mine does not show up on my computer but when I log into the forum from a computer running MS stuff, it does.

March 01, 2012
by Rick_S
Rick_S's Avatar

Ok if I'm understanding you correctly, you are wanting to create an entirely new environment using the microcontroller used with the Nerdkit (168 or 328P) as the wizard behind the curtain. It would essentially become Bill Gates PC and the project would be the equivalent of MS-DOS for developers. It would have basic input via a 9 button keypad, output via an LCD and sound via a piezo element.

When you said this:

The stock instruction set will be specially selected to teach programming while they create chasers and a game of slalom or "pong" on the display. Once they have a good understanding of structured programming they can learn about the compiler and begin writing their own instructions and make the gadget into a customized dedicated widget without the burden of development from scratch.

I What language will the end user be using to create these programs? Will they be proramming in an interpreted form of C?

This whole project seems quite overwhelming to me. Especially to think of putting all that into the limited resources of a micro-controller. Of course, computers I started with in the early 80's had less functionality memory and speed wise and they did fine.

I guess it's hard for me to grasp the whole picture of this project as I've not seen anything similar. You have an advantage in that you know exactly what you want. You've done it before and have seen it work.

What would be an example of how, if the project were completed, an end user would display "Hello World" on the LCD?

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

There are several details yet to be determined in order to answer your question, namely the instructions and which language to emulate. Let's say we agree on a simplified ASSEMBLER language as is outlined way up in this thread. Using only those instructions, an example program might look like this:

//From the main menu, select the screen builder function. //Input the address of the table to hold your LCD output. //Using the cursor keys, construct your message one line at a time. ( up to 12) //Return to the main menu. Select Edit program. //Enter the program counter value where you want this routine to reside in EEPROM. //Using the cursor keys, select the instruction and provide data (parameters).

//Mov A,1 //Assume 1 is the function "Text" //Xch A,B Swap A and B regs //Disp,B Call Display function 1-16. "Your Message Here"

alternatively: the body of the program could look like this:(simplifed)

//Mov DP,### //Table address. //Mov Y,00 //Indexing pointer. loop entry point:// P1,M(DP+Y) Port1 < Mem(DP+Y) Port1=LCD // //Inc Y //Jmp ### //Loop entry point.

Out of time for now, what are your thoughts?

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

That got all boogered up.

Mov A,1 //Assume 1 is the function "Text" 
Xch A,B //Swap A and B regs 
Disp,B //Call Display function 1-16. 
"Your Message Here"

alternatively: If you are creating this function:(simplifed)

0000 Mov DP,### //Table address. 
0005 Mov Y,00 //Indexing pointer. 
0008 P1,M(DP+Y) //Port1 < Mem(DP+Y) Port1=LCD 
0009 Inc Y 
000A Cmp Y,## //Check for end of file.
000D Jmp 008 //Loop entry point.

This code would ideally be written to one of the USR function locations and its vector defined using the memory editor. The function could then be called using the first example above. The "main()" could be a single instruction.

Ufunc1 //

Using the memory editor, this function can be named or done later using the compiler.

We build upto 16 display functions that can be called with a simple Disp,B. If the function is deemed worthy of implementing into the OS, it is written in native 168 and added to the flash.

The entire operating system is written using whatever you ae using now. Embedded C is my first choice because learning it is the reason I am doing this project. The OS in this dev device is simply a monitor to create an Integrated Development Environment that promotes Rapid Prototyping of an idea. Let's blink an LED.

0000 Mov A,5    //Delay value = 5 //5 selects a declared value in our Delay function.
0002 XCH A,B    //Delay value now in B reg. We created a function to swap registers.
0003 Mov DP,PORTB //Data Pointer set to Native port address. 
0007 Mov Y,01   //Indexing Pointer set to Port Bit 1.
000A Setb,(DP+Y)  //  LED ON
000B Dly B       //Call delay function and pass delay value in B reg. ON delay
000C Rstb,(DP+Y)      // LED OFF
000D Dly B          // OFF delay
000E Jmp 00A      //Loop forever

I would like to develop an instruction set that most closely emulates the bitwise operators inherent to the 168's microcode. A good example is the XCH A,B function. VUAR is the register we defined to hold both the A and B virtual registers. The monitor calls the function that looks like this: SWAP VUAR and Return. This is native code for the 168 and minimizes the overhead clocking required by the monitor.

I think it's great that you have asked these questions.

March 01, 2012
by Rick_S
Rick_S's Avatar

OK, I think I'm starting to see your picture a little more clearly. All I can say is WOW Eek

The idea is sounding much more interesting to me. I've always wanted to learn assembler but never have dedicated the time to understanding it enough to do anything. So it would be very interesting to have a standalone development platform for that.

I'm seeing now, that I'm understanding more of what you are wanting to do with this, why my comments frustrated you so. I should have started with more questions and discussions as I had most of your concept wrong. I'm more than a bit embarrassed now. Embarrassed

Anyway back to topic, I do think your project could be interesting. To be totally honest though, while I could somewhat follow the code you wrote above, your level is beyond me to the point I don't quite understand all you are trying to convey. What I'm saying is that I understand some (most) of the assembler commands you used in the code but I have to re-read your post to grasp the bulk of it. I couldn't begin to know how to write the code you did above for something as simple as that in assembler. It interests me but seems beyond me ... maybe not ... I don't know. I'm sure it's something I could learn though. I always say, I'll quit learning when they put me in the ground.

I will also say that I don't know how much help I would be with the project because I am far from an efficient, experienced programmer. I either know enough, or have taught myself enough, to do what I've needed for the various interests I've had, but most of my code is pretty bloated due to my lack of knowledge. I'd like to see this kept alive though. Also, if there is something I can help with, if time is available, I'd help out if I could.

Anybody else?? I know we have experienced programmers on here that are far better than I.

March 01, 2012
by Ralphxyz
Ralphxyz's Avatar

Well seeing as this is supposed to be for the new programmer.

I have looked at assembler and made a led light so my assembler programing is very limited but I would understand assembler itself better then what I have seen so far.

I know that the dialog has actually been focused on getting "experienced" programmers involved.

4bits4e4, you might just have a couple of under qualified beta testers.

Ralph

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

I sense enthusiasm. The project is really no more difficult than some of the fragments of code already written here in the forum. We just need to put the pieces together into a finely tuned structure that does what we want. I'll continue to fill in some holes in the outline with actual code as time permits. I'm sure you'll pick up on the idea that it is just another program manipulating the peripherals in a prescribed order, yielding a useful tool. The 4bit52 is a much more complex program than I have planned for the 168 and I think the whole of it fits in 8k of flash, albiet there are no library files to bloat the code.

Machine language is far simpler to learn due mostly to the absense of syntax, and more flexible because you control the hardware intimately. Controlling the hardware requires a thorough knowledge of the inner workings of the processor and this is what intimidates some programmers. Once you understand any processor, learning another is an easy task but requires rewriting the code using the new instruction set. C is very popular because of its portability from one processor to another without having to rewrite the code, however, the programmer writing the port utility is a machine language programmer.

This project is no more complex than any other C program. We write functions to create the various features of our virtual machine (the environment). We write more functions to emulate a programming language (Instruction set). The language doesn't have to be assembler, it could PLC logic, HMI, or CNC or any combination. I'll be writing my initial instruction set to emulate the native 168 instructions and the functions will manipulate the peripherals. Eventually some of the instructions will become more complex and the functions could become entire programs.

March 01, 2012
by 4bits4e4
4bits4e4's Avatar

Ralph, This forum is full of experienced programmers! A particpants value is measured by their contributions, be they code snippets, creative thought, a wish list of features, or cheer leaders.

Once the project is under way, those less experienced coders ask some of the best questions to aid in creating clear documentation. All experience levels should find the progression through the project educational and some may be greatly enlightened.

Because the code is highly modularized, there will be dozens of useful routines to cut and paste for experimenting outside the project. A keypad debouncing sceme that gets some work done instead of sitting in one spot wasting clock ticks. A keypad scancode generator, key repeat function, parse a keypad scancode into a function call independent of other functions.

The screen builder routine allows the user to enter text directly into memory using the keypad. A screen can be upto 12 lines or 240 characters. Build as many screens as you have memory to hold them. Write the screens to EEPROM and use them for pop-ups on internal or external events. Use the 16 available display routines to control a single line or the entire screen. Scroll a 240 character message.

We'll be learning how to create a single step program debugger. The program stops and displays the registers, Data pointer, and the next instruction to be executed. We'll learn how to dynamically throttle the run speed of our running program.

These are just some of the items on my wish list!

March 01, 2012
by dvdsnyd
dvdsnyd's Avatar

@ 4bits4e4

I want to apologize for my previous post. You came here, to engage a community. You did so very enthusiastically too. I obviously did not see the potential or lacked the knowledge necessary to see your vision. As opposed to putting down your ideas and discouraging you, I should have asked questions and attempted to gain a better insight into the project. With that all said, I am truly sorry if I offended you in any way. It was not my intent, but can easily see if you took it that way.

It is my hope that we can all learn from this.

I don't know how much help I would be for such an endeavor. I have a pretty basic goal right now for my hobbyist electronics...develop and build flight computer hardware/software for model and high power rockets...altimeters, timers, stagers...GPS/Telemetry one day....maybe a whole flight computer...

Could something like what I am describing(flight computer) benefit from your project concept?

Sorry for my naive question, but I have just recently taken up the Nerdkit(December 2011- Xmas present from my wife :-) )

I am a 25 year old Mechanical Adjuster, have a degree in Aerospace Engineering. I have programmed in FORTRAN, MATLAB, dabbled in Visual Basic, and have just begun embedded programming. Most of my programming skills come from college and are all very numerical intensive, usually simulations and stuff of that nature. I try to help out on the forums where I can, but have a pretty limited idea of what is going on a lot of the time :) It amazes me when I can get something to work...in a weeks time and 454 compile cycles later.

Reading through some of your posts here and the scope of the project, you are obviously very intelligent and have good intentions of what you want to see happen. I don't want to get in your way anymore, I don't know if I would be much help though, but want to see where this will go that is for sure!

David

March 01, 2012
by pcbolt
pcbolt's Avatar

@4bits4e4

I didn't understand either what you were up to, but then I remembered an electronics kit my cousin used a while back. It was a basic breadboard kit with springs for wire connectors, LED's, LCD display, a bunch of active and passive components etc. The kicker was a built-in micro that you could enter commands into just as you are describing. I believe the instruction set consisted of about 20 commands (4-bit). You entered the program steps in with a 16-pad keyboard and setup output pins to the LED, speaker or LCD. As I recall even with the limited instruction set, you could do some pretty sophisticated things. Since the kit was geared toward learning electronics, most of the projects started w/o the micro, then transitioned into it showing how you could replace a rat's nest of breadboard wires with a tiny chip. Educational to say the least. When I get a hold of my cousin, I'll see if he can remember the name of the kit and if there is a list of the instruction set.

March 02, 2012
by 4bits4e4
4bits4e4's Avatar

David, I'm glad to see that you are still "lurking". While a harsh critque can be humbling, it pales in the face of the realization that I had failed to construct a clear explanation of my vision. I saw some of myself in your self introduction so, how can I not like you? I remember helping a co-worker construct a data logger he intended as the payload of his model rocket. Miniaturization was not what it is today but we managed a high level of success as measured by our own standards. It carried a barometer, accelerometer and thermometer aloft. It included a strobe and RF beacon for location if it experienced an errant flight path. I enjoy the electric radio controlled aircraft hobby and have experimented with some of the early zigbee circuits.

Can this project help with your interests? Can your experience aid this project? Knowledge is intangible and yet incredibly malleable.

March 02, 2012
by 4bits4e4
4bits4e4's Avatar

Pcbolt, I remember a product much like the one you are describing. The Elenco 500-in-one kit or something like that. A solderless electronic experimenters kit with a simple programmable controller. These make great gifts and door prizes, appealing to youth groups involved in scientist search seminars.

I have my nerdkit setup on a proto box I built decades ago. It has switches, LEDs, clock and waveform function generators, and a generous breadboard area.

The 168 can easily be adapted to the Elenco type of application, the menu driven concept of our budding project here may be necessary to overcome the lack of resources for complex keypad. A second 168 could be used as a keyboard controller and its output sent to the 6 bits on PORTC of the central 168. That's 2E6-1 individual keys.

March 02, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Two of your quotes, 4bits.

1-that allows them to watch their code run and see the registers and memory changing value

2-I would like to develop an instruction set that most closely emulates the bitwise operators inherent to the 168's microcode.

Can you draw a picture/circuit of a typical 4bit code running through the chip?

This is kinda where I left off almost 2yrs ago. My title, 'JoeBit's Escape from Program Space' Episode-00.0010. So say if joebit is the third bit and his job is to blink a lcd, from start to finish. Mr Logic is the main guy, lets talk to him first.

March 03, 2012
by 4bits4e4
4bits4e4's Avatar

Farmerjoe, This sounds like an inquiry to what is displayed when using single step run mode. The execution of the program is halted and the user registers, pointers, and program counter are displayed. Example:

____________________
A=F B=F C=F DP=FFFF
Y=FF Z=FF P1=FF
0000 Mov A,F
____________________

The display remains static until the assigned GO button is pressed. The instruction is executed, the register contents are updated, the next line of the program is disassembled and the information is displayed.

March 03, 2012
by 4bits4e4
4bits4e4's Avatar

The reference to the microcode infers that the initial instructrion set will stay "close to the stone" or emulating the native instruction set of the 168 as nearly as possible.

March 03, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Actually more like this, program space is down a ways. I guess there is no escape, at least not this way, a rewrite does that. It would be more an actual path 4bits actually travels through the registers, etc. Simpified.

A fraction of joebits journey

March 04, 2012
by 4bits4e4
4bits4e4's Avatar

I'm not entirely clear as to what you are asking. Are you wanting to implement the function of this comparator in software? Are you interfacing with this device?

// Software emulation
//Acquire the data. Load 2 registers with the data to be compared.
//These use indirect addressing and require that data pointer be setup.
R1, Y+ Load Indirect and Post-Inc. R1 ← (Y), Y ← Y + 1 
R2, X Load Indirect Rd ← (X) // 
// Now compare when CS is active. The Z flag will emulate CS.
CP R1,R2 Compare R1 − R2 // If equal the Z flag is set.
//Use the result of the comparison to set a flag or branch to a handler routine.
BREQ k Branch if Equal if (Z = 1) then PC ← PC + k + 1

If(A==B)
{
  Do this...
}
else
{
  Do this
}

There are no plans to graphically represent the propagation of bits through the virtual registers of this project. Such a low level is of value to a circuit designer but little to a software developer. If I haven't answered your question, feel free to ask again!

March 04, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Yup, you got it. I kinda figured it would be a bit daunting. I was imagining a set of ones and zero's paradeing though the chip.

Say if this piece of code... R1, Y+ Load Indirect and Post-Inc. R1 ← (Y), Y ← Y + 1 R2, X Load Indirect Rd ← (X)

After comipled would look something like 0010 Four bits at a time, times the length of the program, routing through the registers, etc, etc...Like a visual program.

Realizing, this is probably why I left it. Thinking now, tracking the bits in the chip would be unrealist, and far too compicated. I guess this would relate to a see through V8 block, running. Not quite the same thing, oh well, just thought I'd throw it into the discussion.

So now, I've got a another development board that I can't get to do shit, windows or linux, it's not what you got going so I'll throw it up in another thread.

I want to make a life display with running water flashing lights and plants, these frigin tiny ic circuits i've been buying break down after time. One sound activated swithch just quit, still lights but no more sound blink.

Would you write the code for my display if I disign the circuit?

March 05, 2012
by 4bits4e4
4bits4e4's Avatar

I did a powerpoint presentation depicting how the location of the bits in an instruction determine how the instruction is executed in the microcode. This bit says it's a register, the next two give it a number, the next determine if it will go through the ALU etc etc... It was brief but did enlighten several of the attendees. The constraints of the LCD on our Nerdkit makes this type of application impracticable.

I like the picture you painted of a piece of paradise. I imagine controlling outside peripherals like water valves and light sequencing circuits. All very doable! These controllers are available with a mil-spec and their increased robustness may help you overcome most of the device failure you are experiencing. Other factors like reducing the voltage, better hermetics in the final packaging can also help extend the life of the device.

I have been reading a ton on the compiler, the C language, my IDE of choice and the plethora of related documentation in order to get up to speed with these devices. I experimented with the Nerdkit this weekend and wrote several test programs to become familiar with its capabilities and caveats. I would be happy to assist you when you get stuck, however, my skills with this development system are minimal at this time. My enthusiasm will continue to drive me toward milestones and eventually allow me to overcome these shortcomings.

March 05, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

I had lots of fun with win-avr toolchain. My windows box just one day said, no, I don't want to go to work today, and sure as the day is long, she quit. I had the head honcho's working it through with me and nada.

Linux Kbuntu to the rescue. I do all my programming there now. My Dell Latitude XP is my toy.

You got me going on these peripherals, I have to brush-up myself, the 168 is capable of some, but I'm thinking it would be easier with a board with everything included. Vast as usual, the 168 is definatly a great starting spot, can always add to it.

Also: The forum has still got the same quirks, why don't my pics show up now? I mean, I think I can still copy and paste a tiny piece of code.

Can you point me too...These controllers are available with a mil-spec

March 06, 2012
by 4bits4e4
4bits4e4's Avatar

I too have all but given up on the Windows platform, greed drives the company and their goal is to divide computer users into groups of zealots. I am a long time participant in the Free Software Foundation and adhere to the GNU license.

While Atmel makes reference to their milspec compliance, their packaging for the 168 does not exceed Industrial grade. I'm going to suggest that your component failures are due to improper IO interfacing. Designing outside peripheral interfaces involves buffering and /or isolation of the uC and has always been an area where cost consideration plays a major role.

Using buffers on your IO ports is essential and they can be as simple as a diode or as complex as using opto couplers. When interfacing to any processor, it's very easy to exceed the maximum ratings of source and sink currents. Always buffer your IO to keep these currents as low as possible and the dependability of the uC will be enhanced.

I haven't as yet found a need to include photos in my posts but, if I did, I would study this link: http://www.nerdkits.com/forum/thread/572/

March 06, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Thanks there, 4bit but that's the exact page I copied and pasted... joe bits daunting task What gives.

Thinking about the micro-code you mention, and I think of Arm. I had no idea there's something similar inside the 168. Would you mind explaining that in more depth. thx. fjc

March 06, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Here's the code...Alt Text

March 06, 2012
by 4bits4e4
4bits4e4's Avatar

Images

Admittedly, it’s fairly difficult to devise a “natural” syntax for placing images into a plain text document format.

Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: inline and reference.

Inline image syntax looks like this:

Alt text

Alt text

That is:

An exclamation mark: !;
followed by a set of square brackets, containing the alt attribute text for the image;
followed by a set of parentheses, containing the URL or path to the image, and an optional title attribute enclosed in double or single quotes.

Reference-style image syntax looks like this:

Alt text

Where “id” is the name of a defined image reference. Image references are defined using syntax identical to link references:

As of this writing, Markdown has no syntax for specifying the dimensions of an image; if this is important to you, you can simply use regular HTML <img> tags.

March 06, 2012
by 4bits4e4
4bits4e4's Avatar

The information doesn't reproduce here accurately. Check the link at the bottom of the page for the Markdown Syntax Documentation. Experiment on this thread, then teach me what you learn.

March 06, 2012
by Ralphxyz
Ralphxyz's Avatar

Farmerjoecoledge, is this what you are trying to show? link

That's doing it as a link:

[](http://www.flickr.com/photos/28711211@N07/6802300504)

Your other image is a link back to this page so I do not know what you were trying to do.

Flickr is not very friendly about linking directly to photos it seems, but you can link the URL.

Ralph

March 06, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

I don't got a clue...Ralph, but that 'is' the url, add what is a 'hotmail tag'?

These are thumb nail images from various sites, if that helps.

4bit, I click on your image and nada, too.

March 06, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Here, I got it...Copy and Paste this Link in your Browser. :|

http://www.flickr.com/photos/28711211@N07/6802300504/

March 07, 2012
by Rick_S
Rick_S's Avatar

To show the image from flickr, the only way I see is to select share, then HTML/BBS code. Then from the code in the window just grab the actual image link and post as instructed below. Like this:

url=http://www.flickr.com/photos/28711211@N07/6802300504/

Rick

March 07, 2012
by 4bits4e4
4bits4e4's Avatar

Here is a stand alone version of the scancode generator for the 4bit Nerdkit.

// 4bit Nerdkit using Atmel 168.
// by 4bits4E4
//Scancode generator
#define F_CPU 14745600
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"

//Inputs
#define row0 (1<<PB3)
#define row1 (1<<PB4)
#define row2 (1<<PB5)

//Outputs
#define col0 (1<<PB0)
#define col1 (1<<PB1)
#define col2 (1<<PB2)
uint8_t scancode;

//**************************************************************
//
// Init routine
void init()
{
    DDRB = ~(1<<DDB5)|~(1<<DDB4)|~(1<<DDB3); //rows = Inputs
    DDRB = (1<<DDB2)|(1<<DDB1)|(1<<DDB0); // cols = outputs
    PORTB = ~(1<<PB3)|~(1<<PB4)|~(1<<PB5); // pullups on = neg logic
    lcd_init();
}
//////////////////////////////////////////////////////////////////
//    0   1   2
// 3  09  0A  0C
// 4  11  12  14
// 5  21  22  24

int main() 
{
    init();
    uint8_t col;
    uint8_t row;
    uint8_t pins;
    row=0;
    scancode=0; 
    while(1)
    {

        PINB = 0x00;    //All cols low
        for(col=0;col<=2;col++)
        {   
            PINB |= (1<<col); //Walking 1, PB0=0 ,1 ,2
            for(row=3;row<=5;row++)
            {
                pins = (PINB & 0x38);   //Read port and mask columns

                while(pins)
                {
                    scancode = PINB;
                    pins=0x00;              
                }
            }

            PINB &= (1<<col); // Turn off walking one
            lcd_line_two();
            lcd_write_string(PSTR("Scancode= "));
            lcd_write_int16(scancode);
            lcd_write_string(PSTR("  ")); 
        }
    }
}
March 07, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Joebit can't post images...

<a href="http://www.flickr.com/photos/28711211@N07/6948411533/" title="420px-Von_Neumann_architecture.svg by archiejohn2008, on Flickr"><img src="http://farm8.staticflickr.com/7176/6948411533_a2c656a622.jpg" width="420" height="400" alt="420px-Von_Neumann_architecture.svg"></a>

That's the Hotmail/BBCode

Here's the Alt Text with Hotmail/BBCode... Alt Text Joebit sick

Here's the url...http://www.flickr.com/photos/28711211@N07/6948411533/in/photostream

4bit, That's a Language then? So to learn this a guy would pretty much be dedicated, I use to have tons of patients and I'm happy when things work, but give up really easy now.

Maybe I'll throw my pieces together and try and post another pick, and take it from there.

Ps. Humberto use to post the picks for me before when they were like this , I never have successfully done it myself, kind of embarasing, I useally catch on fairly quick.

March 07, 2012
by Rick_S
Rick_S's Avatar

From the code you posted:

<a href="http://www.flickr.com/photos/28711211@N07/6948411533/" title="420px-Von_Neumann_architecture.svg by archiejohn2008, on Flickr"><img src="http://farm8.staticflickr.com/7176/6948411533_a2c656a622.jpg" width="420" height="400" alt="420px-Von_Neumann_architecture.svg"></a>

The filename of the image is "http://farm8.staticflickr.com/7176/6948411533_a2c656a622.jpg" out of that text you posted. If you want to display that, all you have to do is type and exclamation point, open and closed brackets, then that address in parenthesis like this.

![](http://farm8.staticflickr.com/7176/6948411533_a2c656a622.jpg)

Then you get this:

March 07, 2012
by 4bits4e4
4bits4e4's Avatar

Joe, This code will be a part of the BIOS in the Nerdkit monitor project. It is a polling routine to look for a keypress on a 3x3 keypad. Future revisions will be called by a timer interrupt and include a key click sound and key repeat detector routine. You expressed interest in knowing how to read inputs from buttons so I posted this early version for you to study.

March 07, 2012
by pcbolt
pcbolt's Avatar

@FarmerJoe - Keep the faith bud. You don't give yourself enough credit.

@4bits4 - My cousin got back to me about the 500-in-1 kit. You're right it was distributed by Elenco and went by the name Maxitronix. The instruction set was as follows:

IN, OUT - Input/Output to default port
MOV - 3 modes; AX <-> number; AX <-> mem; AX <-> address @ mem (<-> bi-direction)
ADD, SUB - 2 modes: AX +/- number; AX +/- mem
AND,OR,NOT,XOR - 2 modes: AX &,|,~,^ number; AX &,|,~,^ mem
ROR, ROL - 2 modes: ROR/L AX; ROR/L mem
INC, DEC - AX +/- only
JMP, JZ, JNZ, JC, JNC - Abs Jump; Jump on/off zero flag; Jump on/off carry flag 
CMP - 3 modes; AX <==> number; AX <==> mem; AX <==> address @ mem, then sets/clears Z/C flag
BON, BOF - Turn sound On or Off
TM1, TM2 - Timers TM1= msec; TM2= sec
STP, NOP, SEC, CLC, HEX - Stop, No Op, Set CFlag, Clear CFlag, Enter Hex # (for jumps)

As you can tell there are no provisions for function calls (no stack, no pop/push) but as I said before, you can do a lot with a little...which I think is the basis for your project. As far as this kit being a door prize, you have to invite me to some of your parties. I could flip a kit like this on E-Bay for about $200.

It looks like you are off to a good start. Right now the best I could do is kibbutz. I think I would write the scan code for a 4x4 pad, then transition, educationally of course, to using an 8-bit shift register so we could free up four of the six pins.

I'm still curious about the "monitor" you choose to use. The LCD alone might suit you well for the beginning.

March 08, 2012
by 4bits4e4
4bits4e4's Avatar

pcbolt, Thanks for the info relay, some of these instructions will be implemented in my project. They are pretty common from one processor to the next, arithmetic and logic, branching, looping and register and memory definitions. Not too different from any computer language. One of the primary tasks of the monitor is to provide a programming environment free of the tedious housekeeping inherent with machine language programming. Much like any higher level language, the programmer can "just write code" without being burdened with a lot of administrative details.

The bootloader in the 168 is a good example of monitor code. It allows us to flash it over and over without having to worry about the "bootstrapping", a real time saver.

I'm thrilled that you're curious about the project, that characteristic will put you at the top of the heap in your future endeavors. Polling a 3x3 matrix or a 104 PC keyboard, this routine is the basis of finding the active row and column and returning a globally defined scancode. Any function in the application can now translate the code into useful data, cursor control, volume control etc. Rather than using a shift register and coding to control and interpret, a second 168 would be a good choice for an intelligent keypad controller. A 4x4 matrix is 16 keys and 8 port bits while an 8 bit scancode from this keypad encoder will control 255 keys or outside events.

Using the LCD supplied with the Nerdkit is essential to achieving my primary goal of creating a "useful" program that any Nerdkit owner can experiment with. It may be possible for some version of the project to utilize a more complex display as a tier 2 interfacing experiment but, it is more likely that mine will use a smaller and very low power reflective display.

Thanks again for your "curious" comments. I'll do my best to be of value here.

March 08, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

We have another night owl amongst us, I do make a routine, sort of, do my best work after 11pm. When you guys get this, Good Morning!

thx pcbolt, long time.

4bits The microcode looks simple enough, what would the learning curve be,from 1-10?

I have to tell ya, when I was at this before, I couldn't quite get a grasp of the debugger. I mean even after the code runs, joe-logic fucks things up or a gate failed to open, etc, etc. Just that code work was too daunting. I'll tag along see what your following comes up with. thx, great chatten, the weed forums are quite boring compared to here, Cheers.

Rick, Finally, hey?

March 08, 2012
by 4bits4e4
4bits4e4's Avatar

Joebits, Flattening the learning curve for budding programmers is a secondary objective of this project. While assigning an arbitrary number to effort would have value in a marketing campaign, in this forum it would promote dis-interest. If a number were assigned, I would choose a 3 namely because:

The number of instructions to learn and remember are minimal.

The chosen instruction set makes possible the rudimentary structures and addressing schemes of all programming languages.

The complexities of human machine interfacing are moved from the chapter titled "getting started" to somewhere in "the middle of the book".

While the project does boast being a good beginners tool, that statement is based on the idea that some of the work involved to learn programming will only be deferred to a later time in the learning process. To infer that it robs the user of ability to learn the subject is erroneous. Instead it very well may be THE experience that sets in motion an insatiable desire to spend the next 30+ years of their life learning.

My effort in this forum is manifold.

Firstly, I get to create and develop something of interest to me while learning something I want to know.

Secondly, interested programmers are invited to contribute to the project however they wish to satisfy their selfish needs. :)

Thirdly, to provide a learning tool.

To those that have expressed interest and have cheered me on to this point. Thank you!

Phil

March 08, 2012
by 4bits4e4
4bits4e4's Avatar

The debugger in this project will be a simple pause and display routine. The screen builder will be used to gather the registers, memory values, and the next instruction to be executed. A second and third info screen can display a memory dump and some environment variables. Once you can correctly predict the changes made by each instruction, your program should be running without error and you are a programmer.

It is important to mention that the called functions written in native code will not be single stepped. Instead, only the programs written in the virtual environment using the interpreted instruction set will be disassembled and displayed. This includes any higher level functions you've created using the tokens.

A debugger can be much more complex than this but, it's a good starting point.

March 08, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Hello Phil,

Couldn't help it, but this quote is missing two words. Good thing it doesn't include me, I'm the copy/paste guy. :)

Secondly, interested programmers are invited to contribute to the project however (it seems) they wish to satisfy their selfish needs. :)

Don't be offended, just trying to keep the piece.

And me, if I start now I'll be 73 by the time the learning curve is over, just in time for my 'Eternal Life Circuit'. Just got to figure out how to 'seal' the blood in.

Grant

March 09, 2012
by 4bits4e4
4bits4e4's Avatar

Joe, I'm not entirely clear why you chose to paraphrase those words, none of the statement above was intended to stab at anyone. The early critiques of my suggested project were not offensive, just out of place. Though late, I felt it would be beneficial to address those earlier concerns and give what solace I could regarding the projects value. Having the perception that it would fuel the imagination of prospective participants, the introduction of the idea was intentionally brief, as was the follow-up.

Engineer types have a propensity to tear things down, change them and, present them as new and improved. Somehow, when that process was applied to this idea, it got stuck in step one. That has changed some and I've had the opportunity to expand the introduction to include more detail. Had I spent more time to present the project differently, its reception may have been different as well. The project is progressing slowly but will gain momentum once I become more proficient at using this development system.

I'm still committed to update the forum on my progress and remain hopeful that once the program takes shape it will become of more interest.

March 09, 2012
by Rick_S
Rick_S's Avatar

Wow Phil, you must be an early bird like me if you live out on the west coast... Must be around 4AM there. I usually get up between 4 and 5AM.

I didn't take your phrase the way Grant did. I took it more to mean that each participant would have something personal to gain from what they would contribute. Thus their contribution would "satisfy thier selfish needs"

Rick

March 09, 2012
by 4bits4e4
4bits4e4's Avatar

Rick, I've been in the Eastern time zone since 1993 and usually find a few minutes in the morning to check emails and the such before heading out. Lately I've been taking the time to add to this thread as it allows me to focus on the objective here.

My greatest struggle with this project thus far is to find the time to work on it. I caved in and ordered "The C Primer 5th edition" in the hopes that it will expedite filling some of the holes in my high level language knowledge. I read Richie's book but it is somewhat outdated. I also read "Programming Embedded Systems" from ORielly, I has some good info but only about 20% relative.

I have written several bench test programs on the 168 trying to find the best approach to using it. Last night was one disappointment after another trying to implement the timer interrupt for the keypad scan. The overhead on the CPU clock just isn't justifiable. I thought that because the project is all about the keypad and display that having 3 to 5 polls of the keypad per second would work well. Even the 16 bit timer interrupt is 60 Hz and would require too much code to re-scale it for this purpose. I'm looking into using the Watchdog to handle keypad scan calls. May know something this weekend.

March 12, 2012
by 4bits4e4
4bits4e4's Avatar

Played with the WDT to trigger keypad calls. Idea abandoned. Much easier to control the output of keypad function when the call is deliberate. Have a substantial start on the BIOS, over 300 lines of code this weekend. Re-writing the lcd library for hex display and lcd_init to change cursor settings. Cursor control functions are also underway.

Hoping to have IO on the screens done this week. From there its on to the environment.

March 14, 2012
by Farmerjoecoledge
Farmerjoecoledge's Avatar

To insert a live link do

nope, here: (http://www.scientificsonline.com/wind-power-2-0-kit.html)

This kind of thing would be a piece of cake for you. All could get the same thing. It would be endless entertainment, watching the volts add up, wireless, of course.

Kind of toy-ish, but thought I'd see if it would fit. All the data can be read on a any cheap monitor.

Farmerjoe

March 15, 2012
by 4bits4e4
4bits4e4's Avatar

I've been a fan of Edmund Scientifics since I was a kid. Still have one of their static electricity detectors I bought with my allowance. Nobody likes these instructional type toys better than I do and some are a good value for the knowledge gained.

March 18, 2012
by 4bits4e4
4bits4e4's Avatar

Been working on the Nerdkit monitor. The BIOS is a mess until I figure out this memory structure. The environment is about 30% done. Have enough of it running to give you a demo of the project scope. The structure is intentionally linear to accommodate profuse annotation at this stage. Have learned a lot so far and, having fun!

// 4bit Nerdkit Monitor on Atmel 168.
// by 4bits4E4
//Development release: 1.1.0.20120315
//
// FREE & CLEAR license agreement: It's FREE ! Is that CLEAR ?
//
// Be a member of the Free Software Foundation: http://www.fsf.org/
// Respect the code: http://www.gnu.org/copyleft/gpl.html
//

//////////// Load gobs of libraries for worst case bloat //////////////
#define F_CPU 14745600
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h> 
#include <inttypes.h>
#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
//#include "./4bitnerdkitmod.h"

//////////////////Header file stuff /////////////////

//Inputs
#define row0 (1<<PB3)
#define row1 (1<<PB4)
#define row2 (1<<PB5)

//Outputs
#define col0 (1<<PB0)
#define col1 (1<<PB1)
#define col2 (1<<PB2)
#define piezo (1<<PC0)

void keypad(void);  //Prototype declarations
void run_program(void);
void edit_program(void);
void view_memory(void);
void edit_memory(void);
int blips();
void whistle(void);
FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putchar, 0, _FDEV_SETUP_WRITE); 
uint8_t screen=1;       //The screen we are working in.
uint8_t scancode;   //keypad return val
uint16_t program_counter=0x00;  //Program Counter
uint8_t position =1;    //cursor[position]
uint8_t run_mode;
uint8_t run_speed;
//////////////////// Init routine /////////////////////////////
void init()
{
    //Keypad matrix port setup
    DDRB = ~(1<<DDB5)|~(1<<DDB4)|~(1<<DDB3); //rows = Inputs
    DDRB = (1<<DDB2)|(1<<DDB1)|(1<<DDB0); // cols = outputs
    PORTB = ~(1<<PB3)|~(1<<PB4)|~(1<<PB5); // pullups off
    lcd_init();
    lcd_set_type_command();
    lcd_write_byte(0x0f); //set cursor on and blinking
    DDRC |= (1<<PC0);
    PORTC |= piezo;
    return;
}//end

////////// LCD MAP //////////////////Keypad //////////////////////
///____________________        
//|00000000001111111111|    
//|0123456789ABCDEF0123|       
//|--------------------|             _PB0
//|44444444444444445555|            |    _PB1
//|0123456789ABCDEF0123|            |   |    _PB2
//|--------------------|            |   |   |
//|11111111111122222222|        |----|----|----|        
//|456789ABCDEF01234567|   PB3--|0X09|0X0a|0x0c|
//|--------------------|        |----|----|----|
//|55555555555566666666|   PB4--|0x11|0x12|0x14|
//|456789ABCDEF01234567|        |----|----|----|
//|--------------------|   PB5--|0x21|0x22|0x24|
//                              |----|----|----|
//168 Memory Map
//32 Registers              0x000-0x01F
//64 I/O Registers          0x020-0x05F
//160 Ext I/O Registers     0x060-0x0FF
//SRAM                      0x100-0x4FF
//Flash (w/boot section)    0x000-0x1FFF
//EEPROM 512 bytes           0x22-0x21      EEARH-EEARL
////////////////////////////////////////////////////////////////////

void menu()
{
    blips(2,40,80);
//Array to hold cursor boundaries
    const uint8_t menu_screen_cursor[] = {0,0x0e,0x0f,0x10,0x16,0x56,0x21,0x61,0};
    position=1; //cursor(position)

/////////////////Menu Screen data ///////////////////
    screen=1;
    lcd_clear_and_home();
    const prog_char mainmenu[]=
    {"   Address= 0x        Run        View    Program    Memory    Edit       Edit   "}; 
    fprintf_P(&lcd_stream, PSTR("%s"), mainmenu);

    lcd_goto_position(0,menu_screen_cursor[position]);
    fprintf_P(&lcd_stream, PSTR("%x"), program_counter);
    lcd_goto_position(0,menu_screen_cursor[position]);
    while(screen==1)
    {

        keypad();               //getkey
        if(scancode)            //if key    
        {
            switch(scancode)    //find key
            {   
                case 0x0a: switch(position)     //Key pressed = "UP"
                            {
                                case 1: program_counter+=0x100;break;           
                                case 2: program_counter+=0x010;break;
                                case 3: program_counter+=0x001;break;
                            }   
                        break;

                case 0x22: switch(position)    //Key pressed = "DOWN"
                            {
                                case 1: program_counter-=0x100;break;
                                case 2: program_counter-=0x010;break;
                                case 3: program_counter-=0x001;break;
                            }           
                        break;
                case 0x11:  if(menu_screen_cursor[position - 1])    //Key Pressed = "LEFT"
                            {                                       //If not out of bounds
                                position -=1;                       //Decrement position
                            }
                        break;
                case 0x14:  if(menu_screen_cursor[position + 1])    //Key Pressed = "RIGHT"
                            {                                       //If not out of bounds
                                position +=1;                       //Increment position
                            }
                        break;
                case 0x12: switch(position)     //Key Pressed = "SELECT"
                            {
                                case 4: screen=2;break; //Run Program

                                case 5: screen=3;break; //Edit Program

                                case 6: screen=4;break; //View Memory

                                case 7: screen=5;break; //Edit Memory
                            }
                        break;
            }//endswitch    
            if(position<4) //Update Display of Program Counter
            {
                lcd_goto_position(0,menu_screen_cursor[1]);
                fprintf_P(&lcd_stream, PSTR("%x"), program_counter);
            }
            lcd_goto_position(0,menu_screen_cursor[position]);  //Undo display auto increment
        }//endif
        scancode=0;
    }//endwhile
    switch(screen)
        {
            case 2: run_program();break;
            case 3: edit_program();break;
            case 4: view_memory();break;
            case 5: edit_memory();break;
        }
    return;
}//end

/////////////////// Program Run Screen //////////////////////////
void run_program()
{
    blips(2,60,80);
    screen=2;
    lcd_clear_and_home();
    const prog_char run_program_screen[]=
    {"      Run Mode=      1=Throttle Spd=0x0  0=Full Speed        2=Single Step    Go"};
    fprintf_P(&lcd_stream, PSTR("%s"), run_program_screen);

//Array to hold cursor boundaries
    const uint8_t run_screen_cursor[] = {0,0x0f,0x27,0x66,0};
    position=1; //cursor(pos)
    uint8_t run_mode=0;
    uint8_t run_speed=0;    
    lcd_goto_position(0,(run_screen_cursor[position]));

    while(screen==2)
    {
        keypad();               //getkey
        if(scancode)            //if key    
        {
            switch(scancode)    //find key
            {   
                case 0x0a: switch(position)     //Key pressed = "UP"
                            {
                                case 1: if(run_mode <2)
                                        {
                                            run_mode+=1;
                                            lcd_goto_position(0,run_screen_cursor[position]);
                                            fprintf_P(&lcd_stream, PSTR("%u"), run_mode);
                                        }
                                        break;  
                                case 2: if(run_speed <0x0f)
                                        {
                                            run_speed+=1;
                                            lcd_goto_position(0,run_screen_cursor[position]);
                                            fprintf_P(&lcd_stream, PSTR("%x"), run_speed);
                                        }
                                        break;
                            }//endswitch
                    break;
                case 0x22: switch(position)    //Key pressed = "DOWN"
                            {
                                case 1: if(run_mode>0)
                                        {
                                            run_mode-= 1;
                                            lcd_goto_position(0,run_screen_cursor[position]);
                                            fprintf_P(&lcd_stream, PSTR("%u"), run_mode);
                                        }
                                        break;
                                case 2: if(run_speed>0)
                                        {
                                            run_speed-=1;
                                            lcd_goto_position(0,run_screen_cursor[position]);
                                            fprintf_P(&lcd_stream, PSTR("%x"), run_speed);
                                        }
                                        break;
                            }//endswitch            
                    break;      
                case 0x11: if(run_screen_cursor[position-1])    //Key Pressed = "LEFT"
                            {                                   //If not out of bounds
                                position -=1;                   //Cursor position -1
                            }
                    break;
                case 0x14: if(run_screen_cursor[position+1])    //Key Pressed = "RIGHT"
                            {                                   //If not out of bounds
                                position +=1;                   //Cursor position +1
                            }   
                    break;  
                case 0x12:  if(position==3)     //Key Pressed = "SELECT"
                            {
                                lcd_clear_and_home();
                                lcd_write_string(PSTR("Running Program"));
                                lcd_line_three();
                                lcd_write_string(PSTR(" Press Menu Key"));
                                whistle();
                            }
                    break;          
                case 0x0c:  menu();break;       //Key Pressed = "MENU"  
            }//endswitch    
            lcd_goto_position(0,run_screen_cursor[position]);
        }//endif
    }//endwhile

    return;

}//end

/////////////////////Not yet started////////////////////////////////////

void edit_program()
{
    blips(2,50,90);
    screen=3;
    lcd_clear_and_home();
    fprintf_P(&lcd_stream, PSTR("%x"), program_counter);
    lcd_write_string(PSTR(" Mov A,0")); //Demo Data
    lcd_line_two();
    lcd_write_string(PSTR("002 Mov Y,00"));
    lcd_line_three();
    lcd_write_string(PSTR("005 Clr, Disp"));
    lcd_line_four();
    lcd_write_string(PSTR("007 Mov DP,000     N"));

    while(screen==3)
    {
        keypad();               //getkey
        if(scancode)            //if key    
        {
            switch(scancode)    //find key
            {   
                case 0x0c:  menu();
            }
        }//endif
    }//endwhild
    return; 
}//end
//////////////////////Under Construction////////////////////////////////////
void view_memory()
{
    whistle();
    //Indiscriminate memory peeking may cause confusion, aka RESET.
    //see memory map.
    uint8_t buffer[0x20]; //32 bytes per screen
    program_counter &= 0x07f0; //0x0hh0  Need More Constraints
    uint8_t *memaddr = &buffer[program_counter];
    uint8_t counter;
    screen=4;

    lcd_clear_and_home();   
    fprintf_P(&lcd_stream, PSTR("%x"), program_counter);
    lcd_write_string(PSTR(" "));

    for(counter=0x000;counter<=0x020;counter++)
    {
        fprintf_P(&lcd_stream, PSTR("%x"), *memaddr);
        memaddr++;
        switch(counter) //Divy the data onto 4 addressed lines
        {
            case 0x008: lcd_line_two();
                        fprintf_P(&lcd_stream, PSTR("%x"), program_counter+counter);
                        lcd_write_string(PSTR(" "));
                        break;
            case 0x010: lcd_line_three();
                        fprintf_P(&lcd_stream, PSTR("%x"), program_counter+counter);
                        lcd_write_string(PSTR(" "));
                        break;
            case 0x018: lcd_line_four();
                        fprintf_P(&lcd_stream, PSTR("%x"), program_counter+counter);
                        lcd_write_string(PSTR(" "));
                        break;
        }//endswitch

    }//endfor
    lcd_goto_position(0,1);  //edit program counter
    while(screen==4)
    {
        keypad();               //getkey
        if(scancode)            //if key    
        {
            switch(scancode)    //find key
            {   
                case 0x0a: program_counter+=0x010;view_memory();break;
                case 0x22: program_counter-=0x010;view_memory();break;
                case 0x0c:  menu();
            }
        }//endif
    }//endwhile
    return;
}//end
/////////////////////////////////////////////////////////////////////
void edit_memory()
{
    blips(2,70,90);
    screen=5;
    lcd_clear_and_home();//Under Construction
    lcd_write_string(PSTR("DP=0x"));
    fprintf_P(&lcd_stream, PSTR("%x"), program_counter);
    lcd_line_two();
    lcd_write_string(PSTR("  Edit EEPROM Only"));
    lcd_line_three();
    lcd_write_string(PSTR("  maybe SRAM too"));
    lcd_line_four();
    lcd_write_string(PSTR(" Write  Erase  Next"));

    while(screen==5)
    {
        keypad();               //getkey
        if(scancode)            //if key    
        {
            switch(scancode)    //find key
            {   
                case 0x0c:  menu();
            }
        }//endif
    }//endwhile
    return;
}//end

////////////////////////////////////////////////////////////////
void single_step()  //Demo Data
{
    lcd_clear_and_home();//01234567890123456789
    lcd_write_string(PSTR("DP=0x123 Y=12 Z=34"));
    lcd_line_two();
    lcd_write_string(PSTR("A=1 B=2 C=3 Flg=0"));
    lcd_line_three();
    lcd_write_string(PSTR("000 Mov A,0"));
    lcd_goto_position(3,20);
    lcd_write_string(PSTR("G"));

    return;
}

///////////////// Sound /////////////////////////////////

void click()
{   
    uint8_t k;              
    for(k=0;k<10;k++)
    {
        PINC |= piezo;
        delay_us(20);
        PINC &= ~piezo;
        delay_us(20);
    }   
    return;
}

int blips(num,dur,freq) //Beep num times, duration, frequency
{       
    uint8_t k;              
    uint8_t j;

    for(j=1;j<=num;j++)
    {   
        for(k=0;k<dur;k++)
        {
            PINC |= piezo;
            delay_us(freq);
            PINC &= ~piezo;
            delay_us(freq);
        }
        delay_ms(freq);
    }

    return(0);
}

void whistle()
{
    uint16_t k;             
    for(k=40;k<1220;k+=10)
    {
        PINC |= piezo;
        delay_us(k);
        PINC &= ~piezo;
        delay_us(k);
    }
    for(k=1220;k>40;k-=10)
    {
        PINC |= piezo;
        delay_us(k);
        PINC &= ~piezo;
        delay_us(k);
    }
    return;
}

////////////////////Keypad scancode generator///////////////////////////
//PORTB     0    1    2
/////     |------------|        
/////  3  |09 | 0A | 0C|
/////     |------------|
/////  4  |11 | 12 | 14|
/////     |------------|    
/////  5  |21 | 22 | 24|
////      |------------|

void keypad()
{

    uint8_t column;
    uint8_t row;
    uint8_t row_high = (PINB & 0x38);
    scancode=0; 
    if(row_high); //then key pressed
    {
        delay_ms(50); 
        for(column=0;column<3;column++)
        {   
            PINB |= (1<<column); //Walking 1, PB0=0 ,1 ,2
            for(row=3;row<6;row++)
            {
                row_high = (PINB & 0x38);   //Read port and mask columns
                if(row_high) //then key found
                {
                    scancode = PINB; //1 col and 1 row
                    click();

                    while(scancode == PINB)
                    {
                        ;; //wait for key up
                    }
                }//endif
            }//endfor           
            PINB &= (1<<column); // Turn off walking one            
        }//endfor
    }//endif

    return;
}//end

///////////////////EEPROM READ / WRITE/////////////////////////
//EEARH and EEARL – The EEPROM Address Register
////Bits 8:0 – EEAR[8:0]: EEPROM Address
//EEDR – The EEPROM Data Register
////Bits 7:0 – EEDR[7:0]: EEPROM Data
//EECR – The EEPROM Control Register
////Bits 5, 4 – EEPM1 and EEPM0: EEPROM Programming Mode Bits
////Bit 3 – EERIE: EEPROM Ready Interrupt Enable
////Bit 2 – EEMPE: EEPROM Master Write Enable
////Bit 1 – EEPE: EEPROM Write Enable
////Bit 0 – EERE: EEPROM Read Enable
//void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
//{
/* Wait for completion of previous write */
//while(EECR & (1<<EEPE))
//;
/* Set up address and Data Registers */
//EEAR = uiAddress;
//EEDR = ucData;
/* Write logical one to EEMPE */
//EECR |= (1<<EEMPE);
/* Start eeprom write by setting EEPE */
//EECR |= (1<<EEPE);
//}

//////////////////////////MAIN ///////////////////////////////
int main() 
{
    init();

    while(1)
    {

        menu();

    }
}

//////////////////// To Do List //////////////////////////////////////
/*
 * key function parameter passing with pointers
 * pointers to trim modular linear structure
 * binary display?
 * build mod4bit.h
 * garbage collection
 * 
////////////////////// * NOTES:////////////////////////////////
 * //--section-start sectionname=org 
    //Start section sectionname at absolute address org. 
    //-Tbss org
    //-Tdata org
    //-Ttext org 
    //Start the bss, data, or text section at org, respectively. 
    * 
    int lcd_putchar(char c, FILE *stream) {
  lcd_write_data(c);
  return 0;
  * 
  * //fprintf_P(&lcd_stream, PSTR("string"), var);

/////////////////////compiler commands////////////////////
// Optimize -O1 or just leave out
// remove -j .text for malloc
// -ffreestanding 
//Assume a "freestanding" environment as per the C standard. 
//This turns off automatic builtin functions (though they can still 
//be reached by prepending __builtin_ to the actual function name). 
//It also makes the compiler not complain when main() is declared with 
//a void return type.

//-mno-wrap 
//For RJMP/RCALL instructions, don't allow the target address to 
//wrap around for devices that have more than 8 KB of memory.

//-funsigned-char 
//Make any unqualfied char type an unsigned char. 
//Without this option, they default to a signed char.

//-funsigned-bitfields 
//Make any unqualified bitfield type unsigned. By default, they are signed.

    */
March 18, 2012
by 4bits4e4
4bits4e4's Avatar

Be sure to remove -j .text from the MAKEFILE. Uses fprintf_P. Feel free to comment or contribute.

March 21, 2012
by pcbolt
pcbolt's Avatar

4bits -

Two quick questions. First, are you going to use the EEPROM to store the user's code instructions? Second, will the final program need "fprintf" functionality? I found out the earlier in development I stayed away from using it, the easier it was to get rid of it entirely later on. Not that I'm not a big fan of "fprintf", it's just when you mentioned "code bloat" before, that's the first thing I think of.

March 22, 2012
by 4bits4e4
4bits4e4's Avatar

pcbolt, The instructions will be in flash, the EEPROM will be used for the user programs written using the monitor. The memory structure of the 168 poses stumbling blocks for this type of application. In keeping the monitors usage of SRAM down to a minimum, I have chosen to store the constant strings using pgmspace and retrieve them using fprintf. Any ideas on another method would be welcomed!

The bloat can/will be reduced by importing just those functions needed from the various libraries so the #includes can be reduced. The code is well over 600 lines at this point and I foresee 1000 lines but, don't have any real concerns about running out of flash yet. My goal is to make this an open application using the "stock" Nerdkit configuration and libraries to keep the familiarity for any interested experimenters.

In the interim of development, I plan to post some useful stand alone utilities I have developed while becoming familiar with the chips' architecture. The memory view utility is nearly complete and I feel others may find it useful and enlightening. The keypad and menu functions can also be useful and adapted to expedite the development of other projects.

The listing is humongous and I need to find an alternate method for posting updates so as to not "bloat" the forum threads.

March 22, 2012
by Ralphxyz
Ralphxyz's Avatar

4bits, this should definitely be in the Nerdkit Community Library you wil not have to worry about forum bloat and one can easily link to it from the forum.

Ralph

March 22, 2012
by 4bits4e4
4bits4e4's Avatar

Ralph, Thanks for the directions. It will be quite some time before I have anything more than modules working. The project is far from final but, considered to be somewhere close to the halfway point. I write some code, get it working, then re-write it using different structures while benchmarking for efficiency. Fun but, time consuming and it keeps development releases few and far between. As I become more proficient at this C language and the peculiar compiler, I'll be contributing more often.

March 30, 2012
by 4bits4e4
4bits4e4's Avatar

UPDATE: Ran out of flash memory to hold a project of this magnitude. Have to include so many libraries that I'm left with insufficient space to write the code. It will probably fit on the 328 but then the original intent of making it available to all NerdKit users would be lost. I'll be posting some of the modules as stand alone utilities and continue to create some applications. It's sad but, this 168 project is at an end.

March 30, 2012
by pcbolt
pcbolt's Avatar

4bits -

That's too bad. As mentioned before, if you get rid of the "fprintf" functions, you can most likely free up about 6.5K of flash. Still might not be enough for this kind of ambitious project.

March 30, 2012
by 4bits4e4
4bits4e4's Avatar

I have more to learn. I can figure another way to print variables in hex but displaying constants from program memory poses a problem with my limited knowledge. Maybe I can just rename the project to 328 monitor!!

March 30, 2012
by pcbolt
pcbolt's Avatar

You can use the Nerdkits LCD library for that...it's pretty small.

Post a Reply

Please log in to post a reply.

Did you know that a piezoelectric buzzer can be used in reverse as a microphone? Learn more...