We need to change a controller code from the out side as they do with industrial MCU .
So that you have an mcu,with a program on it, and someone can program some "words" to it, that will determine how it works.
So for example you can program an mcu -not with a programer but with some inputs from serial, to do some simple things such as:
if input A==1
b=1
I wonder if there is a smart way to do that with simple software on the mcu, that it has many #defines for various commands, and it perform them according to values it gets from the outside (and saved for the rest of the program).
I wonder if the industrial programers are using that method, or that every programing of a user is actually load a code(.hex) to the chip(with internal programer ) .
I prefer the simplest way(i wonder if its by pre defined software)
A couple of options come to mind so hopefully this answers your question. It sounds like the simplest version of your question is "How do I change the behavior of the MCU without an actual MCU programmer?" A couple of options come to mind.
1) Depending on the MCU you can have a bootloader that is essentially a small piece of code programmed in the MCU by a programmer that has the ability to reprogram other parts of the MCU. This doesn't require a programmer but involves some other form of letting the bootloader know what the new code is (USB, Serial, SD Card, etc). This will only work if the MCU has the ability to self flash.
2) Again, depending on MCU and scenario you could program a generic set of rules that carry out functionality based on the inputs given to the MCU. This could be in the form of IO pins, EEPROM, or a domain-specific script on an SD card that the MCU can read and interpret at runtime.
Both options depend on the MCU you are using and what hardware capabilities you have at your disposal. But you certainly have options other than reprogramming the end hardware with an actual programmer every time you want to make a change. Hopefully that helps.
Related
I recently started coding on a raspberry pi. I build a circuit with three buttons, an LED and a 7 digit LCD. Its a fairly simply thing. You can set a time value with the + and - button in seconds and then press the other one to start a countdown. I use this to do triggered long exposures with my camera. However the raspberry pi is to big and bulky and needs to much energy.
Then I put my code and my circuit on an Arduino UNO which is an improvement in size and energy consumption.
Because my program is very simple I am sure that there must be a way to get this on a much smaller chip. I need some kind of programmable chip where I can put my code onto. Something that is small and dont has any other fancy features or more calculating power than I could need. As far as my knowledge goes I dont have any idea how to get into that.
At work we have a 3D printer with a W1209 temperature relay controller on it. This is a small circuit with the same 7 digit LCD pane and the temperature is also settable with two buttons. This inspired me to look for something much more primitive that would be enough for my needs.
Can you recommend any hardware or some tutorials about that?
Search the Microchip website for the DM164141 - MPLABXpress PIC16F18345 Evaluation Board. I think it's around $12 and should have enough I/O for your application. You can use the online MPLABXpress IDE for development.
I always wondered how this works . In arduino IDE we have option to select different boards because the code upload i guess is different ? Also there is possibility to even add board manager url to add other boards.
Why uploading the code is so different from board to board , and what exactly differs there ? The code is sent to via serial connection and i understand that a board might have different chip for handling USB to serial but ..
Can someone explain as clear as possible , how the code is uploaded to a board and why there is no generic way , why so many configurations.
Thanks and sorry if is a dumb question.
One of the important things that selecting a board does is, as you say, inform the IDE of how to load code onto the board. Perhaps more importantly, the board definitions give you the logical mapping of the board's hardware to the code constructs you are using to program against. For example, have you ever wondered what happens when you use a constant like PIN_13, or how that constant maps to a physical pin on your board, which has a trace to some contact on the microcontroller chip itself?
There is a lot of other code you don't see, much of it in the board definitions (and some in the Arduino core) which lets you work with relatively direct concepts (like pin numbers and modes) in the code that you write or edit.
I've currently developed a BLDC motor controller and it generally works fine. During some events however the microcontroller locks up (e.g. stopping the motor or fast changes of duty cycle). Because of this, I want to isolate the microcontroller from the power side (i.e. isolated supply and optocoupled signals) the issue however is I'm using sensorless control and am wondering what the best way of relaying the phase values back to the microcontroller would be?
I currently detect the zero crossing in software and use this to commutate my phases (as per the Microchip AN970 amongst others). I'd rather not use comparators on the power side and optocouplers to send back a digitized version of the phase voltages as I want to have the ability to change the trigger point.
I've looked at isolation amplifiers but they seem pretty expensive and I was wondering if there were any potentially cheaper solutions.
Thanks
Maybe have a look at this document:
https://www.silabs.com/documents/public/application-notes/AN614.pdf.
We use this design, but in a total different application. I dont' really know much about BLDC motors but maybe it helps.
kind regards
Here is my issue, it appears that all the communication lines for the PIC 16F913 reside on the same set of pins, this is convenient in that I don't have to sacrifice GPIO pins just to do comms, however the problem I'm having now is if I'm using the SPI on the chip, how can I send information to the RS232?
The reason this issue came up, is that I just bought a CAN bus chip that communicates over SPI, and I would really like to see the data on RS232, so I can see messages. (I really don't know much about CAN yet, so who knows if this even makes sense yet).
Here are the options I see, and maybe someone else has better ideas that I'm just simply missing.
Somehow setup a time scheme that will switch between SPI and RS232 every time I get data,
-- This doesn't seem hard and should work, but supposing I don't want to miss a message, what if a message is written while I'm writing to RS232, is it possible I'll miss it?
2.. I can always use SPI, but then build my own comm bus over 8 of the GPIO lines, to another PIC 16F913, using only the GPIO lines and then since the RS232 lines are free on the second PIC I can simply read the data and spit it out.
-- This one is doable but now we're wasting 2 chips, AND all the GPIO lines,
There has to be a better way. Or is there?
Any help is greatly appreciated.
Update: I would like to clarify, obviously one solution is using a completely different chip (which may in fact be what I end up doing, if I can get the 18F programmed), however, I'm interested in worst case scenario, in which I am limited in resources and only have some 913's, is the way described above the only way to do it with this chip, or is there a better way?
You could do a software implementation of the SPI bus - it's easier to do than the UART because the timing isn't critical and you are in control of it.
Most CAN chips have a few receive buffers so if you're busy doing something with the UART then the messages will be buffered inside the CAN chip. But... you will need to make sure that you can get the messages out of the CAN chip fast/often enough so you don't lose some.
You would probably have to either use an interrupt for the UART Tx process - so that you can be receiving CAN messages while you're sending data on the UART.
If you're only interested in certain messages most CAN chips have filters - this makes it easy to only receive the messages you're interested in, usually dropping the number of packets/second dramatically.
You can use a software implementation of a RS232 port. For example the c compiler from http://mikroe.com comes with such a library. But it shouldn't be too hard to shift bits to an output pin, rs232 is a fairly simple protocol.
I strongly recommend that you change the MCU with PIC16F1933.
It is newer
It is cheaper
With EUART and MSSP moduls.
The MCU arhitecture is impruved.
The PIC16F913 MCU will become obsolete in next few years!
Besides Arduino, what other ways are there to learn hardware programming in a hands-on way? Are there any nifty kits available, either a pre-assembled robot, that you can program to move a certain way, or do certain things, or anything similar to that?
Atmel AVR and the PIC both have experiment boards that you can use solder stuff on to, usually they have a couple of buttons and some lights pre-soldered to the area. This let's you program/flash the microprocessor and play with the output pins. You can either write the programs in assembly or C.
Parallax have a number of kits. They have two product lines suited for "playing around", Basic Stamp and something called Propeller. The former is a small microprocessor that runs programs written in Basic (a tad disgusting ;)) and the latter runs something called Spin or assembly (well after compilation obviously.)
I would go with either AVR or the PIC. I've done PIC but I've heard good things about AVR, they seem to ship with better software.
At first look Microsoft's VPL sounds good, but when it comes to actually LEARNING how hardware works it goes a LONG way to hide those details from you. As a matter of fact it is pretty much designed for people who don't program, and is distastful to someone who's actually written embedded software. IF you just want to make stuff happen and not delve into the details it's fine, but if you want to get down to the metal like programming the "Arduino" boards it's not for you.
If you're used to something like the Arduino then something like the PIC will be an easy transistion. SparcFun Electronics has all sorts of DIY type projects and hardware available. If you have a decent bookstore around your area, I would suggest looking for "Circuit Cellar" magazine. It has articles on a monthly basis with project for someone looking to get into hardware projects, everything from homebrew Software Defined Radio to FPGA based 3D graphics. (Raytracing actually) Usually the authors describe the project in an article and "WHY" they made the decisions they did, a description and schematics of the hardware and provide a link to source code.
Cypress Semiconductor has one of the most interesting embedded processors on the market and several high quality dev boards for sale. The PSoC includes the ability to not only configure the software, but also to "drop in" software configured hardware such Analog to digital converters, serial I/O, Digital to Analog and Various amps and filters. It's a REALLY cool concept, and the "touch sensor" capability of the PSoC were actually used in several models of the IPod.
One thing about programming these little micros is they don't have a lot between you and the hardware, you get to see how things really work. It doesn't matter whether you're talking about an 8-bit microcontroller or a quad-core Pentium programming hardware is largely the same concept. You write to a memory mapped register for some piece of hardware like a serial controller, and the hardware responds in someway. If you program a baudrate generator in a PIC or PC it's largely the same idea, you write a value that will be used as a division factor from a given clock to achive a given baudrate. The numbers and names maybe different, but the concepts is the same. On a PC you may have to map to the PCI address of the card, which adds a some complications, but if you looked underneath the OS you would see that that was done just by writing values to registers simalar to programming a PIC to use a different "Page" of memory. Is it worth learning an 8-bitter? Well, there are approximately $5 billion dollars in sales of the little 8-bit micros today with projection only showing growth in that market in the future. I saw one reference that state the average car has 25 Microcontrollers in it. That's not too bad.
I haven't played with it much, but the iRobot looks pretty cool.
The ability to simulate how your robot will work which some of the other answers mentioned is nice, but there's nothing like seeing a real-life robot do what you programmed it to do. That, to me, is what really makes robots fun and cool.
There's the .NET Micro Framework.
It's incredibly simple to use/setup and there's lots of hardware being made to target this framework.
You should take a look at Microsoft Robotics Developer Studio which supports many different kits.
I have always been curious about gumstix. It seems more professional than arduino, and it aims at the Linux programmer. I cannot give you a real suggestion, as I've never played with it, but I would definitely go with one of this toys if I had to do and learn some cool hardware programming.