Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by enl

  1. docs are the references above from TI. Google for SLAU319 and 320. This is really not a 30 second, one paragraph thing to answer. The protection is provided via a number of options using the same interfaces that are used for programming.


    The option with BSL is to set the password (32 bytes, which is a 256bit password) that will be required for the read command to be used to read the code memory, either via JTAG or BSL. Disabling JTAG reduces the risk of several possible exploits that can get information without an explicit read (see the docs on the CCC website for more info).


    NOTHING can provide absolute security. I could decap the IC an use several methods to directly read the code memory if I wanted it bad enough (well, I personally couldn't at this time, but some of my former students could, and I could have when I was still in university, and, now that I think about it, maybe I could now, but I would need several samples to work with, and I wouldn't bet my house on it). More work than in the old days of mask programmed ROM, where you could pretty much read the data with an optical microscope, but still not a major challenge with appropriate gear. ANY security you use can be broken, and the issue is whether it is some guy in his basement, or if it requires equipment that only someone with enough money to reproduce you work from the ground up anyway will have.


    Edit: 32*8 is 256 bit password, not 512. I have become too used to working with 16bit words over the last few years....

  2. For information about the MSP430, see SLAU319, "Programming via the bootstrap loader", SLAU320, "Programming via the JTAG interface", and SLAU265, "MSP430 Memory programming" (outdated and superseded by the other two, but still useful)


    A summary: disable JTAG and password protect BSL access.


    If future access will be required for in circuit reprogramming, there are a variety of options, but the essence is that you set a password that prevents protected commands, like reading the program memory, via JTAG or BSL

  3. In addition to undersampling the signal leading to loss of proper representation, the clock on the processor is NOT as accurate or as precise as a crystal oscillator. If the timing in your code was nominally perfect, it would still likely not match the real-world waveform timing, and not read at exactly the same point on the real world waveform each time, even if the real world wave had no error, which is unlikely. Undersampling IS used for a number of practical applications, but great care is needed to do it properly.


    Another issue, that again would affect you even with perfect clock, is that the delay(20) puts a 20 microsecond delay BETWEEN the instructions before it and after it. The 20microsec does not account for a) the time required to do the function calls and ADC conversion, B) the time to save the value to the variable ADCvalue, c) the time to copy the value into the array element, d) the loop overhead. Depending on the processor clock speed, the overhead will be a couple microseconds at 16MHz to maybe 100 microsec or more at 1MHz.

  4. Short form:


    One interrupt is shared by all pins on a given I/O port. When the specified transition occurs on the pin (low to high or high to low), several things happen: The transition sets a flag in the port's interrupt register so the program can identify WHICH pin triggered the interrupt. If the processor is asleep, it is woken up. Then, the interrupt routine is called, which disables maskable interrupts.


    The line you asked about clears the interrupt bit for P1.3 so that the interrupt isn't retriggered when the interrupt handler ends. When the handler ends, unless you specify that the processor state should be different, it will go back to the same state it was in when the interrupt occurred, until the next one comes along, in your case LPM0.


    The #pragma specifies to the compiler that the function following is to handle the port1 interrupts, so the compiler places its entry address in the appropriate interrupt vector location.


    When running, it is all automatic: The transition happens, the flag is set, triggering the interrupt response of wake up. The hardware identifies which interrupt(s) came along, gets the target function address from the appropriate memory location, and does a call interrupt sequence.



    Bad form: putting a loop in an interrupt handler. In a toy/learning program, it is ok, but it should not be done under normal circumstances, as it forces other interrupts to be locked out, and if the same one occurs while in the routine, it can't be serviced.

  5. At those currents, if you have the linear reg in hand, and can mount the heatsink, it will do the job. I have done such many times (back in the 70's and 80's, linear regs like the 7805 or LM317 were all we had off the shelf), and it works.


    But, as Spiralis said and I followed, the switcher reg is the better choice. The OKI-78SR he referred to is about as good as they get for off the shelf price/properties balance for this type of application. Never used that one myself, as I have a collection of switching drivers and inductors from an assortment of past projects, most of which were paid for by others, and just roll my own when I need to.


    Another option I didn't mention is, for low duty cycle applications, like 100uA 99% of the time, 100mA or an amp 1%, is use rechargeable cells and a low current maintenance charger. I have used NiMH (previously NiCd's) and AGM's a number of times this way. 1A 2% of the time and microamps the rest requires about 25 or 30mA from the charger to maintain the battery. Drawback is battery life issues, but, especially for things that need to stay alive for a bit with no power at all, this works well.


    In an auto application, I would also suggest a good filter at the input. There are commercially available filters for noisy sound systems which are usually just an L-C. (See second in attachment)


    If using a filter, I would suggest a zener or other protection device at the output side to clamp any major spikes to 20V or so.


    edit: put linear rather than switcher... need sleep


  6. Well, a lot of options, depending on application...


    What current? Is it relatively constant? Do you need 1/2amp?


    If the draw is below 25mA to 50mA average (over a time <1sec), the basic linear reg is a good choice here, as it is cheap and regulates well. At 50mA, you will be dumping about 500 to 600mW, which is into the range where you need to worry about rejecting the heat with a heatsink. Greater than 50mA, definitely a heatsink and other choices are likely better.


    Constant current (or fairly constant) up to the limit for the unit allows for the use of a series ballast power resistor to drop voltage and dissipate heat


    My choice would be a switching regulator rated for automotive conditions (buck configuration) to 3v3, OR a switching reg to 4.5V, followed by a 3v3 low drop out regulator, if I need silky clean output. I might even just modify a $5 phone charger to deliver the 3v3, if I had one around, as even the cheapies use a buck configuration switcher (caveat: there are some that go beyond cheap to the level of trash.... they are often scary)

  7. A few questions:


    What is the value representing?

    What range does the whole number part take??

    Do you need to store more precision than the three digits after the decimal for any reason, or only those three?

    What RESOLUTION do you need? (0.001? 0.005? other?)


    Options, depending on the details, roeadrunner84's solution, where you maintain the float until the string generation, using the TI fixed point library for all of it, or doing the fixed point yourself using integers.


    For me to make a decision, I would need to know more detail, but my default would be the TI fixed point lib instead of float throughout the application, if possible, as it is faster than float, and likely smaller to build.

  8. The first thing is that the numeric values, such as in the line `P1OUT = 01000000;' are treated as octal values due to the leading zero. Without a leading zero or base specified, numerics are treated as decimal. As you intend this to be binary, you can try `0b01000000'. Some compilers will accept this as binary, though it is not standard. The best way is use hexidecimal: `0x40', which all C compilers will accept.

  9. transistor isolates the output from the MSP430 from the higher voltage.


    General electronics content: The npn transistor is off (no base current) until the emitter is significantly - about 0.3 or 0.4v - below the base voltage of 3.3v. Yes, the base-emitter junction acts as a diode, But the relevant part is the emitter current and the base current  act as the control current for the collector in the beta gain model of a bipolar junction transistor. As the transistor turns on (when the emitter is pulled below the base voltage), current can flow from the collector to the emitter. The collector acts as a pure current sink (ideally) with an infinite impedance, which isolates it from the emitter and base. Effectively, the potential at the collector is hidden from the emitter and the MSP430 pin can't be damaged by it. The base current of the pnp transistor will pass through the npn transistor (out the emitter) and needs to be sunk by the MSP430 output. From the point of view of CURRENT, it is the same (in opposite polarity) as driving the LEDs with an non transistor as a ground-side switch. In this circuit, the npn transistor is solely acting to isolate, not to amplify.


    A rectifier won't do this. The potential at the emitter of the npn BJT can not be pulled higher than the base by the collector (unless the transistor is damaged...)  if only a diode was used, there would not be isolation. (I will note that there are a number of ways to put a diode in this circuit instead of the transistor... none of them will provide the isolation, though some of them will provide the desired operation for at least a little while)

  10. Next is putting in the second stage planet gears, first stage carrier/second stage sun, and first stage gears. Liberal use of good grease is recommended. I used lithium, but any plastic and aluminum safe NLGI 1 grease is fine.


    Last is put the pinion back on the motor, slip it in, and reinstall the spring pins.


    Then the drive is done. I reinstalled the original case parts so I won't need to make a special mount


    Dis-assembly is the reverse of assembly. Tweezers and needle nose pliers are key. Wipe parts and keep them clean.


    This unit has a net reduction of 81: two 9:1 stages... 6 tooth sun and 48 tooth ring. The planet carriers float, making tolerances less critical, and the planet gears are reduced tooth count: they have 19 teeth, should nominally be 21. Doesn't effect the ratio, and is probably to make assembly easier as they are a little smaller. Grease can move around a bit more easily with the extra clearance, and 19 is prime, so the teeth share load. BandD probably did this solely to make assembly cheaper.



    Experience tells me that this should last pretty much forever in intermittent use, if not driven at stall loads, and as a drive for a wheeled robot, several hundred hours.


    But that is for another time.






  11. Here is why the rebuild was needed: there is a brake built in to keep the outshaft from backdriving the motor. Problem is, once engaged, the motor can't turn. The outshaft needs to go to zero torque and slightly reverse to release it. It has to go to use the drive reliably in any project.


    IMPORTANT for ANY device with a torque limit clutch:

    Before dis assembly SET THE CLUTCH TO THE LOWEST SETTING so spring pressure is released, or you will be hunting pins and springs later



    The first pic shown the output shaft half of the output coupling. The six (three pairs) of jam rollers are actuated by the not quite flat faces, and are wedged against the inside of fixed ring. Much like an overrunning cluch. The three pins sticking up (at 12 oclock, 4 oclock, and 8 oclock) are the torque clutch pins. The springs are under the pins and sit on cam plates set by the torque limit control. They are what the ring gear reacts against, so if any are missing, the drive will not work.


    Next two are the other half of the coupling, which is also the planet carrier for the second reduction. The slots clear the rollers, and the keys fit in the slots on the other half.


    Next the jam rollers removed


    Then the second stage carrier/half coupling installed, and the ring gear (stator for both reductions, as well as the key piece of the torque limit clutch) ready to go in next. The six bumps are the clutch. At any time, three of them are against the three spring pins. Overtorque causes them to push the pins down so the ring can rotate one sixth of a turn.






  12. Spent some time prepping for a new project, and realized I haven't seen the techniques I use shown, so I figured it is as good a time as any. There are likely people that could use the information, and I have a cat on my lap, so I have time.


    The project I am working on (to be disclosed if I get it done to m satisfaction) requires a pretty high torque, fairly fast drive. The requirement is to move about 10mm in 100mS, position withing 0.1mm, with a force of about 50N (3/8" motion to about 0.004", with a force of about 10Lbs, for those that are trapped in the world of imperial units). Not earth shaking, but beyond the cheap hobby servo.


    The cheapest, and one of the most convenient, moderate torque drive available is the battery screwdriver. Not the big gun shaped job, but the homeowner type. The good one are about $20US new, but I usually pay $0.50 to $1.00 at yard sales and swap meets. There are millions of them. Most with little to no use. People buy them for themselves or as gifts without realizing that this little bugger in not the same as the $150 Dewalt. After they sit in the drawer unused for a few months or years, I get them cheap. They have been around for at least 30 years, with 1/4" hex drive, planetary reduction, 180RPM nominal, and design voltages of 2.4 to 4.8V.


    The one I dissected this time tests out at about 250Ncm at 1V, with a no load speed of about 70RPM. The design voltage is 3.6V, and it will probably stall at close to 1000Ncm (10Nm) at that. If more is needed, then I can up the voltage for short bursts. I doubt that will be the case, as at 1V, I have much more torque than I need using a 15mm arm. For the output shafts and actuator levers, I use 1/4" allen wrenches, also yard sale grabs, preferably unhardened, so the cheapest sub-harbour-freight quality is fine. If they don't stay in place themselves,a little epoxy or gel CA does it.


    For this project, the first thing I did after ditching the battery end (should have been second) was mount screw terminals. There are no electronics. The switch presses contacts directly on the motor terminals, and the battery was mounted in the swivel handle. All gone, and nice big holes (12mm dia) through the body for mounting and reaction against torque.



    The first and last show the parts I used and the installed terminal. Clean and fairly neat. Last shows a sampling of the drivers in my junk box. All are black and Decker. Models are LI2000 (3.6V LIon, 330g as it sits), which is a current model,. I use this one for its intended purpose.  9078 (the one being remodeled here), which is 380g as it sits without battery or handle. Heavy. Metal gearcase. Next is a 9071, about 15 years old. 2.4V and 440g. Last is a 9018,, maybe made in 1985 or so. 2.4V and 250g. Only the first cost over $1


    Edit: fixed image




  13. This will damage the port pin in the MSP430, and may destroy the device. On or off, the pin will be exposed to 12V- the BE drop.


    I will reference you to the input stage of TTL logic as the basis for the attached. The transistor acts to isolate the pin on the MSP430 from the high potential, but all base current for the PNP transistor will be sunk by the MSP430.



    Edit: misplaced resistor in original.


  14. Reverse the bit order of UCBRS=3 data bits, since they are given least to greatest in the table, which actually gives 0x2A, which gives slightly greater max error than the 'ideal' 0x4A, but the same average rate. I am not quite sure why they show 'ideal' modulation in slaa049 rather than the ones that the UART can actually do, but that is what they show.


    If you had UCA0MCTL = 0x06, then that was correct for 32KHz clock.


    DCO clock will allow you to use a larger divisor, so you can get much closer to the correct frequency. It should be more than accurate enough. As I said, It should be fine with the 32KHz clock and appropriate divisor and modulator setting. The other question is: what are you using for the PC side? The launchpad board? a different serial device? The launchpad board should be OK with the modulated clock, in my experience, but some of the USB-to-serial devices I have seen are not very close on the bit rate. That might be a contributor.

  15. Ah... I see.


    UCAxMCTL 15.4.5: Bit 0 is UCOS16. Bits 1, 2, and 3 are for the modulation select. A modulator value of '3' is desired here (as per table 15.4) with a divider of 3. This gives best approximation to 9600 average by being an effective divider of 27/8 (three and three eighths). [32768/9600=3.41, which is about 1% greater than 27/8]. The modulation pattern produced by UCBRS=3 is 0x4A (see table 15.2.... note that the bits are shown in order used, which is low to high order)


    Therefore, you want UCA0MCTL to be 0bxxxx0110. The high order four bits don't matter, as they are ignored when UCOS16 is 0. I would use 0x06 for UCA0MCTL.

  16. Reference for reduced number of mod modes for g2553? I see nothing in the docs, and it has a UCA0MCTL register with no notations that I can see indicating that modulation is modified from the documentation in slau144. I will not exclude the possibility that I am missing something, as I can't recall for sure if I have used modulation on a g2553, though I think I have.

  17. I was going to add to the original post when the system went down, so:


    The 20% error referred to in the table (15-4) is the worst error on an individual bit. The overall error for a given byte is significantly less. A 20% error for a single bit frame shouldn't be a bit issue, as the sample should be taken by the receiver at the center of the nominal bit frame. If both sender and receiver are off by 20%, in opposite directions, there is still some margin. I have used the 32KHz xtal with baud rate modulation without problems, though my default is to just clock the UART whatever DCO frequency I am otherwise using, if the DCO is active. (DCO is not an option in an application that spends most of the time in one or another low power mode)


    Something you might try is set the UART transmit to 2 stop bits. This will provide margin at the receiver for resynch on the next byte. It should not be needed, but I have seen cases over the years where it is needed.

  18. DCO will generally be within 5% (max over operating range is 6%, but it is usually better) when properly calibrated. If the factory data has not been overwritten, then you can set the DCO to one of four calibrated frequencies, including 1MHz and 16MHz to keep within 5 or 6%.


    You can check the calibration against the 32kHz xtal and trim the numbers to get closer, either by modifying the DCO constants or the settings for the UART clock.


    If the 32KHz xtal is already there, then by using more advanced features of the UART clock, you can do a lot better using the baud rate modulator than with only the divider. See slau144, section 15 (in slau144i, it is page 430, and subsection 15.3.9) where one of the examples is specifically 9600baud using the 32kHz xtal.

  19. very nice. Temp depends on the solder being used (lead/tin, lead free silver bearing, antimony or cadmium silver bearing, etc) and the type of joint (large pad, surf mount small pads, wires, etc).  I don't havea temp gauge. Just adjust it til it is right for the job: heat the joint in a few seconds to flow temp. Hotter is generally better if there is a question, as, if the solder or paste is there, as it melts, it will control joint temp. Once melted and flowed, iron is away. Too low a temp leads to overheating components before the solder flows.

  20. Without volatile: The compiler recognises that the loop has no net effect and that the end result will be that b==0. Therefore, the loop is replaced with an assignment.


    With volatile: the compiler presumes that, even if it can't see it, something, somewhere, may be looking at the value of b other than the code in the loop. Therefore, it a.) compiles the code exactly as written, with b.) no optimizations, and c.) not using a register for the variable (it will always be in RAM, with the associated time penalty for access)

  21. Short overview:


    There are several things that come into play with the timing


    a.) the internal ADC clock rate and ADC hardware, which limits you to a practical guarenteed sample rate of about 200KHz. This is due to the required number of clock cycles for an ADC conversion, the tolerance on the internal ADC clock, and the analog circuitry properties.


    b.) How often YOU request the ADC do a conversion.



    To sample at a given low rate, the structure I would use is, roughly:


    Set up a timer to interrupt at the desired sample rate. The interrupt handler requests the ADC to do a single conversion.

    Set up the ADC to do single conversion on the desired input channel and interrupt when complete

    The ADC handler gets he converted value and does whatever is needed to get your main loop to handle it (sets a flag; takes the device out of LPM; whatever)


    The main loop actually handles the data. The interrupts do minimal work: initiate a reading in the timed interrupt and get the data/signal the main to deal with it in the ADC handler.



    There will be little jitter on the acquisitions, as the interrupt latency for the timed interrupt is the principal issue, and is typically less than a dozen clocks. If there isn't a lot of processing to do, you might even get away with 32KHz xtal for your main clock, rather than the DCO, and keep power low while avoiding the wake up latency from LPM. Probably not needed for this application, as the timing isn'y likely to be that critical.

  22. don' bother float.... If the value won't overflow (less than about 650*10^6 decimal), mult by 3 than divide by 100. The mult by three can be done as `(i<<1)+i'. This will give an int value truncated.



    You can avoid the div by 100 completely. After the sprintf, insert a decimal point before the last two digits. This requires that the value is >= 100 decimal, or there won't BE anything before the last two digits. This can be handled by forcing leading zeroes for 3 dig if value is <100 (using a condition and two sprintf's... one for each case)

  • Create New...