I expected to see mention of FMEA (Failure Mode Effects Analysis) - for design (sometimes DFMEA) somewhere in these lectures. I was pleased at the mention of the importance of specifications even though this is a microcontroller seminar.
Diddling a pin on a scope works very well also. We did a fairly complicated project some years back. We had plenty of extra i/o pins but little additional code space, we would just flip pins on and off as we reached certain points in the program. Could also use it to determine how fast our loops were running.
As mentioned in the lecutre, one of my favorite methods is to output text on a serial interface to a computer running terminal so I can track where I'm at and what my values are. Works great on simpler devices like AVRs.
Looks like we have answered all the technical questions. If I or the attendees overlooked your question, try a Google search, and look at data on the Web sites for MCU manufacturers, 3rd-party software and tool vendors, and independent forums. I hope you will join us for Session 5. Cheers. --Jon
Q: I need to learn more about this printer debugging.. is there a blog i can read to undertstand more clearly?
A: You'll probably find information on forums for specific problems. Most troubleshooting "education" comes from the experience of making many troubleshooting mistakes over a long time. You try things and find something that works for you in a given situation. Then tuck it in your bag of tricks, but share it with the newcomers, too.
A: Very difficult to troubleshoot. Like taking your car to a dealer for service, but of course the car runs fine when they test drive it. I'd try to find a signal that glitches or changes state due to the intermittent and use it to trigger a storage scope that connects to a few test points. Using pre-trigger record lets you acquire data before the trigger so you might detect what causes the intermittent problem. OK, how do you collect data before a trigger? The scope continues to acquire data and saves the last X samples. When it gets a trigger it haves those X samples and continues to acquire data for a period (Y) that you set.
Q: We had a major computer failure (intermitent) that turned out to be a bad power supply ($5000 later).
A: That reminded me... Check for 50- or 60-Hz signals in analog circuits. You can pick up noise from nearby electrical circuits. Also, higher-frequency noise from switch-mode power supplies. I have uncovered ground loops that cause problems, too. If you don't check power first you can chase your tail for a long time.
Q: how do you select bandwidth for an oscilloscope?
A: Check manufacturer's data for either a bandwidth number of a number-of-samples-per second number. The bandwidth indicated the frequency at which a signal appears at half its actual amplitude (the -3 dBpoint). So, if you have a scope with a 200 MHz bandwidth, you can probably use it for accurate amplitude measurements up to about 160 MHz (my guess) or perhaps a bit higher. The signals will still provide good timing information at higher frequencies. If you see a samples-per-second value, say 1 Gsamples/second, I'd use 1/10th of that as the bandwidth. That's my rule of thumb. Watch the specs carefully, though, because sample rates can decrease as you turn on more analog channels. If you have big bucks to spend have a sales rep stop by for a hands-on demo with your signals.
Q: How do you simulate an ADC input (e.g. variable potentiometer) in mplab?
A: You need a "stimulus file" that simulated the ADC values. For more info, see Microchip's document, "Getting Started with MPLAB SIM." Here's a link: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2123¶m=en022520
A: Make an educated guess. based on the number of nested functions called. The MCUs will need to push register values onto the stack, too, but I don't know how to guess at the amount of stack that would use. The compiler will set up a stack for you and you can watch stack use in the debugger watch windows. That will also help when you need to determine stack size.
Q Jon, on using this small receipt printers as a debugger: what about the time overhead implied it the communication with the I/O interface?
A: After you connect the printer, you just push one or two bytes into the UART and proceed with the main program. The overhead is small. And during the type of debugging for which I use the small printer, I'm not concerned too much about a few extra instructions or real-time performance.
Q: Pleaes define "bit bashing" for this newbie. Thx.
A: A UART accepts a byte and transmits it automatically in the selected format and at the selected bit rate. Bit bashing means you select a standard output pin and use software to change its state from a logic 1 to a logic 0 and vice versa to create the proper sequence of bits with the proper bit periods (times) for a serial transmission. It takes a bit of doing, but if you don't have an available UART, it's an alternate approach. You might find some "bit bashing" UART code examples with a Google search.
Q: hope that Jon's secret debugging shows up in his book..more elaborately.
A: It's just a connection from a UART output pin to the serial-input pin on the printer. Download a printer manual to determine the codes needed to set up a specific font. You just send ASCII values to the printer to print the corresponding character. Someone noted printers might need a TTL-to-RS-232 interface. That's true, but my printer uses the plain TTL signals. Maxim Integrated Products sells many types of TTL-to-RS-232-converter chips. They're easy to use if you need one.
Q: am used to assembly, want to migrate to c but don't no where to start from.
A: Try an Arduino Uno and buy a copy of "Practical C Programming" by Steve Ouilline. The Uno community is large and you'll find a lot of help online. You just have to make a small investment and jump in.
Q: Are good used scopes and logic analyzers available through used test equipment outlets?
A: Yes. Get a limited warranty and ensure the instruments has been calibrated. You should get a calibration certificate. I have had good luck on ebay but only buy from vendors that supply a lot of technical information. Some say, something like, "I got this ia a lot of stuff when XYZ closed an office, but I don't have any details..." They don't know how to even test and instrument, so I avoid them.
Q: With this Olimex kit, do you program it via a PC and USB cable? Is the programming software included/free? Is there free assembly software for it?
A: Yes, program with TI's Code Composer Studio (free version) and connect from your host PC via a USB cable. I think you also could use TI's MSP-FET430 module ($US 99). This pod supports real-time programming and debugging. A bargain.
Q: Since the questions seemed to have slowed down i will use some of your xbee knowledge. When xbees are set up to run encrypted, is this done once at assmebly time or with each power up of the board? I was hoping to remove xbees from a device and turn off encryption then reinstall them so i can watch and emulate what each pic is saying to each other remotely.
A: In an XBee module you would set the EE (AES Encryption Enable) bit to a logic 1. They you would load the KY register with the 16-BYTE value for the 128-bit AES key. You can use the free X-CTU software to configure an XBee module (via adapter and a USB cable), or you can send it an AT-type command or an API packet via the X-CTU software, or from a serial port on an MCU connected to the XBee module. You cannot read the KY register. Parallax and Sparkfun have USB-to-XBee adapters. Look for my book, "The Hands-On XBee Lan Manual," which should come out in the sprint 2012. It doesn't cover AES encryption, but now you know how to do it.
Q: How to check CRC value in pattern format t verify the communication link?
A: The sender uses an equation or built-in hardware to calculate the CRC value to append to a message. The receiver usually has similar software or hardware and as it receives the data, it calculates a CRC value. The two should match. If they do not, the receiver raises a "flag" or sets an error bit to indicate an error in the received data. The receiver also might ask the transmitter to try again, depending on the type of communication. The receiver also could send a "negative acknowledgement (NAK)" to the transmitter indicate a problem.
Since the questions seemed to have slowed down i will use some of your xbee knowledge. When xbees are set up to run encrypted, is this done once at assmebly time or with each power up of the board? I was hoping to remove xbees from a device and turn off encryption then reinstall them so i can watch and emulate what each pic is saying to each other remotely
@Jon: Did you ever come across wrong wiring? Last week I let my son build a circuit and it took me quite a while to find out why the LEDs wouldn't work separately ... he used one resistor when he should have used four ...
Q: @Jon: Do you follow a specific sequence when debugging a MCU design _not_ made by yourself?
A: I check power first. Many times the power supply is the weakest part of a design--a cheaply built import. Then check the power to the circuit. If those are OK, what does the problem seem to be? I look for external problems such as damaged connectors, burned or extra-hot components, solder bits between contacts, nicks in narrow PCB traces, loose screw shorting contacts--generally the obvious visual things. Then I want to look at operation of external circuits such as serial port, parallel port, USB signals, etc. to get an idea of what works and what doesn't. Only then do I look at the code. That assumes I have the code to work with!
Q: Most microcontollers seem to have 3.3 level voltages. Can anyone recommend good resources to learn about interfacing to 5 v, 24 volts etc. Inputs and outputs..
A: Texas Instruments makes a 5-to-3.3-volt converter chip that also works as a 3.3-to-5-bolt converter. It's the SN74LVC4245A in an SMT package. If you use solderless breadboards or a breadboard with holes on 0.1-inch centers, but adapter boards from SchmartBoard. I use them.
To connect to 24-volt equipment--assuming you don't mean switching high-power loads such as motors or large relays--TI has high-current drivers such as the SN75451B. It will handle 30 volts at 500 mA. TI has other drivers in this family of ICs.
Q: You've listed a lot of digital debugging usb tools. If we were to start with one, which tool would you recommend?
A: Last year I bought a Saleae LOGIC unit and used it extensively to capture and display serial communications as hex values. Wonderful tool for $150. I used the Link Instruments MSO-19 for analog and digital corrrelation. I have a nice old analog scope--Tek 465B-- that I use extensively. I'm a "minimalist" and use tools sufficient to do a job. Don't overbuy.
A problem with using Hyperterminal from Windows is that if you have a new PC, it most likely comes loaded with Windows 7 and it doesn't have a serial port. This happened to me recently. In order to be able to see the messages coming on the serial port from an Atmel EK, I had to use my older Windows XP machine. You can get Hyperterminal for Windows 7 and it's not cheap. The printer idea is fantastic. Thanks Jon fro sharing your idea.
A: They simply present a visual display of logic signals over a set period. You can set a trigger condition to start acquisition of the information when the analyzer detects a signal change or a signal pattern.
The bus pirate is a great way to start communicating with new chips and eliminate everything else from a circuit. At $30 its a great thing to have even if you only use it once or twice, especially when you can also use it to program AVR microcontrollers
To Jon: Your book will be greatly anticipated because I would like a good source of information to read up on. It could also be a good addition to a program like Wireshark which is already set up for analysing large data streams
Q: @ Jon, Regarding the printer you mentioned during the ppt, if I understand it, can an hyper terminal program on a PC do the same job? Can you please say few words on this, I am confused a bit.
A: Sure, you can use Hyperterminal on a PC to display similar information. But can you print it? I like hardcopy for my lab notebook. And when I have a system in the field and not connected to a PC, a small printer gives me output I can analyze right on site without having to scross Hyperterm windows. It's just a matter of how you like to work. Many times I don't stay connected to a PC.
Q: To specify more I know a simple FTDI cable would download whatever data is passed between xbees as it comes off the serial output of the module. The general degugging related question is what kind of software tools are out there to anaylse and clean up the data i see.
A: Got it. I used XBee modules extensively last year and used the Saleae LOGIC logic analyzer to help me sort out the data. I used mainly the API mode for the XBee modules. I have a book coming out in the spring, "The Hands-On XBee Lab Manual," from Newnes-Elsevier that goes through the breakdown of packets and shows how to interpret them. I don't know of any software that does that, but it could be a Visaul BASIC project for someone. Contact me by email if you need more help jontitus at comcast dot net.
Q: Re: power problems with logic circuits. I designed a CMOS (not MCU) circuit for a starlight camera control function, and while it worked perfectly on the bench, it didn't work when hooked up the the camera system. It took a memory storage scope to discover that the pan/tilt function, which was 120 VAC switched by electromechanical relays, was generating extreme voltage spikes that showed up in the logic as spurious signals. Fixing the problem required capacitor filters across every 120 V relay contact.
So if it works in the lab, but not the actual environment, start looking beyond the MCU.
A: Yup. But in the lab you might have found the problem if you simulated the tilt/pan loads and ran 110V to them. Switching loads with relays almost always causes problems, either from RFI caused by the contact closure or by back EMF caused when the relay coil field "collapses." To reduce contact switching, look for a solid-state relay with zero-crossing switching. That arrangement will limit inrush current as the 110V AC line voltage is at zero when the SSR switches.
Q: @Island Al: I have had problems with the optimizer deleting my debug code. Comments?
A: One trick that I have sometimes used in C code is to declare a variable that is being updated or displayed as "volatile". This tells the optimizer that the variable can change in ways that are outside the compiler's purview so it will leave them alone.
To specify more I know a simple FTDI cable would download whatever data is passed between xbees as it comes off the serial output of the module. The general degugging related question is what kind of software tools are out there to anaylse and clean up the data i see.
Re: power problems with logic circuits. I designed a CMOS (not MCU) circuit for a starlight camera control function, and while it worked perfectly on the bench, it didn't work when hooked up the the camera system. It took a memory storage scope to discover that the pan/tilt function, which was 120 VAC switched by electromechanical relays, was generating extreme voltage spikes that showed up in the logic as spurious signals. Fixing the problem required capacitor filters across every 120 V relay contact.
So if it works in the lab, but not the actual environment, start looking beyond the MCU.
A: Jon the 'Secret Weapon' is so interesting tool. Wow, it's cool! Could you tell me a little more about your experience using it?
A: Sure. I use the printer to give me information about when the MCU reaches a specific point in my code, the value of a variable, to print a test message, and so on. I use a UART output and simply load the ASCII bytes into the UART one after the other. It takes a small bit of software to change an 8-bit value into two hex characters, but it's not difficult to do. Decimal numbers take more work, so I stick with hex. Likewise with text messages. I store them in an array and pass the array pointer to the UART code, which them transmits the characters one by one. I hope that helps.
Q: Question: I am trying to reverse engineer a device using xbees for communication. How would you suggest I connect to the serial line and copy the data to my computer and analyse it?
A: If you mean you want the XBee module to "listen" to the RF communications so you can see the packets, etc., it will not do that unless you can get into the shielded portion under the PCB and find the signal that connects the radio front end to the MCU in that section. The serial output on an XBee module doesn't provide that information. TI has "sniffer" software that will give you the packet information. It is a USB plug-in dongle and some free software. Cost is probably under $100. More elaborate sniffers and analyzers cost thousands.
Q: When writing pure software often stubs are used to return values to emulate an external environment, moreso for a program that must interact externally. How do you simulate the effect of interaction before commiting to the actual external environment at the testing stage? ( bottom-up vs top-down approach).
A: Years ago I had to build an instrument to acquire data from chemical instruments. I used a large EPROM to store a simulated waveform and then fed it to a DAC with an R/C filter to simulate the signal. That gave me a "standard" to use for testing. As an alternate, I could have saved this data in memory and written a routine to obtain it form that memory instead of using an ADC to digitize the DAC's output. But, in those days, memory was expensive and processors couldn't address more than 64 Kbytes. Is that what you're getting at?
@vidyadhari, logic analyzer doesnt need verilog/vhdl/c code. It needs some electrical signals as inputs, here in our case, we have a MCU running some C code you write. The situation where you have seen might have an FPGA/EPLD programmed using a Verilog Code. I think you got the difference.
This is an interesting series, and I am getting some basic understanding out of it. Perhaps DesignNews should hold a course on the true fundamentals of how to make a chip do what you want. This curriculim is definitely over and above the basics that a newbie needs to learn (ie someone like me who avoided programming like the plague when in school - and now regrets it).
Q: When writing pure software often stubs are used to return values to emulate an external environment, moreso for a program that must interact externally. How do you simulate the effect of microcontroller-interaction before commiting to the actual external environment at the testing stage? ( bottom-up vs top-down approach)
Use another microcontroller to simulate external environment response?
Q: Q: (posted again) how do the debug pods connect and work. do they connect to a independant device or to my pc.
A: The USB "pods" connect to a microcontroller system with individual wires for sigital signals and an oscilloscope probe for analog signals. The pod connects to a PC through a USB cable, The pod manufacturers provide software that displays the information. Check out the company web sites for more information and examples.
A: No, not directly because all you can store in an MCU are discrete samples, so a sine wave from a digital-to-analog converter show steps between evenly spaced voltage levels. For a pure sine wave, use an external oscillator or a direct digital synthesis (DDS) chip. Analog Devices makes many types of the latter.
One note: A lot of the "Serial" Point of Sale printers are actually RS-232 and will require a signal level adapter between the digital logic levels and the printer. There are many sources of these adapters. Be particularly cautious if you connect the printer transmit line to the embedded project as RS-232 levels will generally exceed the maximum voltage input level to the microcontroller.
question has been my question and tht of many of us. I don't know if there was ever an exact answer. he means a file you can store in your own directory. that would be awesome for later review. thanks jd.
Q: @Jon. How accurate do you think the power analyzers are when they profile each subroutine?
A: They are not perfect because they sample the CPU's program counter at intervals and do not track each isntruction. So you get a good idea of where power use changes and then narrow it down to the actions in the code that cause the power change. From what I have seen it's a good approvimation.
Q: do those power tools work for any c code, from any micro?
A: They work for specific MCUs. Check the Lauterbach, IAR, and Energy Micro sites to find out more. Energy Micro makes a family of low-power ARM chips, so their power-analysis tool works only with their ARM chips.
When writing pure software often stubs are used to return values to emulate an external environment, moreso for a program that must interact externally. How do you simulate the effect of interaction before commiting to the actual external environment at the testing stage? ( bottom-up vs top-down approach)
MiWi and MiWi P2P are proprietary wireless protocols designed by Microchip Technology that uses small, low-power digital radios based on the IEEE 802.15.4 standard for wireless personal area networks (WPANs). It is designed for low data transmission rates and short distance, cost constrained networks, such as industrial monitoring and control, home and building automation, remote control, low-power wireless sensors, lighting control and automated meter reading.
Mrs. Z, the advantage of bit-banging is that it means you can do anything you want with any chip. The disadvantage is that it requires far too many resources to emulate hardware in software, and if you can buy a chip that does what you need it to do in hardware, you should do that.
Mrs. Z, "Bit Bashing" or "Bit Banging" is for emulating hardware that isn't included on the chip. For instance, if you want a UART, or an I2C port, or an SPI port, you can implement these things in software, IF YOU MUST. It is generally better to just get a chip with that hardware on it.
Evaluation boards may not have the final revision of the chip hardware, also. It may only be a release candidate which may have to be updated, but provides a look at what the final hardware will look like generally.
Jon, not sure if it's right to announce this at a competitor website, but Mouser is having a PIC competition, and has VERY cheap low-end PIC boards. These boards would be a good solution for a classroom, if they can only afford one or two PICKITs for the entire class.
Jon, next time you convert a Keynote presentation, convert it to a PDF. Everyone can read it, and the results are pixel perfect. That's how I play Keynote presentations on a PC, when I must. Also, post the keynote presentation too tomorrow! I'm opening it in Keynote anyway!
Jon I'm new at this, been designing new product and equipment for years and understand there are companies that shine and others that can make your project difficult. I will be starting out on small to medium size projects and was wondering if you or someone in the group could point me in the right direction on a particular brand Micr Controller and software that could save me a lot of trial and error. As everyone knows development times are ussually very short.
It keeps me from having to answer many questions about how to spell names. I have no affiliation with any of these companies except for publisher Newnes-Elsevier for which I have a book under contract.
I apologize for slide numbers placed in the lower-right corner, obscured by the logo. I created the slides with Macintosh "Keynote" with slide numbers in the open upper-right corner. It's likely the conversion to PowerPoint format placed the numbers beneath the logo. Sorry.
Focus on Fundamentals consists of 45-minute on-line classes that cover a host of technologies. You learn without leaving the comfort of your desk. All classes are taught by subject-matter experts and all are archived. So if you can't attend live, attend at your convenience.