Jump to content
Forum sending old emails Read more... ×


  • Content Count

  • Joined

  • Last visited

  • Days Won


enl last won the day on June 18 2017

enl had the most liked content!

About enl

  • Rank
    Level 2

Profile Information

  • Gender
    Not Telling
  • Location
  • Interests
    Machining, welding, electronics, woodwork, making, education, tools, toys

Recent Profile Visitors

1,317 profile views
  1. enl

    Project using the FR2311 and DC Motors

    For the sampling strategy, you probably don't want the repeated strategies. If it were me, I would use ADC_SEQofchannels for the two channels. As for the dead zone, I generally estimate then adjust it during testing. The value I tend to start with is about 5 degrees (2.5 to either side of the zero)or 2 to 3 percent for linear slides, unless the pot has very small mechanical range (less than 180 degrees, shorter than 10mm for linear). You don't set this in the ADC. That is pure arithmetic after reading, with an approach described above. There are other approaches.The one above doesn't do it if you need control all of the way to zero (with motors, you usually don't, as there won't be enough torque at the bottom end to turn the motor unloaded, much less with load). As an example: 270 degree pot, and 5 degree dead zone: When reading, the range for ADC12 is [0..0xfff]. That gives approximately 0x10 counts per degree. The sequence I would use is: // n is a signed int to represent the speed // d is a bool for direction //PWM_max is a constant for the max PWM value. Presume the desired values are UNSIGNED in the range [0..PWM_max] scale_val <- PWM_max / 0x800 // this will be computed at compile time. It is more efficient if it is an int n <- ADC - 0x800 // set center of pot at zero if n<0 then d <- false else d <- true n <- abs(n) if n < 0x28 then n <- 0 // dead zone is 2.5 degrees to either side of zero PWM_value <- n*scale_val //scale PWM The 0x28 sets the dead zone width. There are other ways, as well, of you need PWM all of the way to zero, or want independent control of the PWM low end and dead zone width
  2. enl

    Project using the FR2311 and DC Motors

    I can't address everything you asked (I haven't used the eComp) , but as to bidirectional control, that doesn't matter. Presume you get a value in the range [0..0xfff] as your control value. There are several approaches, but they all boil down do, essentially, subtracting 0x800 from the read value to put half of the range negative, and half positive. For the PWM, if you have a bidirectional driver (inputs are a direction and a PWM pulse) you use the sign for the direction output and the magnitude (absolute value) to set the PWM, probably with scaling. For a driver like the 293, you do a bit more in software, but it comes to the same thing. Hold both drives low for stop, Depending on the sign, you pull one high or the other high via PWM. For a setup like this, I might set a 'dead band' around the stop. After abs value, if it is less than some small value, treat it as zero. This makes stopping MUCH less touchy, and makes it much easier to avoid the condition of PWM too low for the motor to run, but still heating up the motor and driver.
  3. You have a wide variety of clock options from 48MHz down to about 10KHz, on board, the ability to use external clocks (crystals or other sources), and direct support for 32768Hz crystals (and others). You can't reliably go beyond 48MHz, but the internal clock generator will give a fairly smooth range down to the low end (I don't recall the bottom end of the DCO, but the LFO-- ultra low power, low frequency onboard unit- is below 10KHz) Most libraries and language families will provide a way to select which clock and set the rate for the DCO or other source. See http://www.ti.com/lit/ds/symlink/msp432p401r.pdf page 123 for summary.
  4. It is a clever solution, and I learned a few things I hadn't realized about the interrupt flags, but I do think it is a solution in search of a problem. To me, it isn't that the interrupt handler is the only way, or always the best way, but that it is simple and has a low penalty in cycle usage and power, relative to polling this way. Fewer clock cycles per loop (single mask to check one bit, rather than several changes to control register states and masks), and, since this is likely to be a rare event at code speed, net minimal hit. Without working out the numbers, I would guess that each NMI costs about twice as much as each polling loop hit in this example (cycles and power), versus much greater saving each loop for the polling operation. Also, the NMI handler is a natural fit to dropping to lowest power states (though the '430 is better than many processor families with regard to wake up from assorted conditions) and allowing the handler to wake up for the polling loop. Can you tell I am not a fan of delay functions that do not sleep the processor? [My first experience with this involved halt on a Z80, with a line frequency-- actually video frame rate-- wake-up used for delay in 8.3ms increments in conjunction with processor HALT... This allowed for wake up as needed, and, by the standard of the times, moderate power savings] Please do correct me if I am missing something here... This isn't something I have really considered with this processor before.
  5. The few times I have needed to do this, I used interrupt handlers that did nothing but set or reset a bit to reflect the state.
  6. As a general rule, you should never use file or directory names with spaces in them. They tend not to work well with many tools, and tend not to work well across platforms, and do not work at all with some environments/platforms. We have all seen the abomination that occurs when a URL contains a space, and some of us have seen environments where some superstar realizes that, on windows, a filename or directory name can consist of nothing but spaces. Have fun with that. It does not help that Windows does not handle paths consistently across contexts, and, though better than in the days of Win95, still does not handle capitalization in file/directory names consistently across all contexts.
  7. enl

    Circuit Help

    Best advice I can give you is to breadboard it. The LM3915 is pretty rugged, as long as you don't mix up the power supply pins, and everything else except the analog switch is, as well. The frequencies are low. This is very bread-boardable. The 4000 series IC's are not as static sensitive as some, but they do take some care. ALL unused inputs should be connected to ground or V+. I generally use about a 10K resistor, rather than direct connection, primarily because there are some failure modes that can occur during power cycling if the inputs are direct connected to V+ or ground, and the resistor limits current generally preventing damage. The unused analog pins should also be connected to ground.
  8. enl

    Circuit Help

    See, for example, https://web.stanford.edu/class/archive/physics/physics105/physics105.2002/datasheets/Analog_Linear_OpAmp_ICs/LM3915.pdf pages 8-21 I like this IC family, and have used them many times for many things. I miss them, but not much.
  9. Does anyone have recommendations for a current probe for use with an oscilloscope? I borrow a Tektronix from work when I need one at home, but a friend now needs one for field work and needs to be able to look at moderately short pulses (1 microsecond-ish), and he needs to buy out of pocket. The low end Tek, which would do the job, are about $700, but there must be other options that are decent these days for 1mA resolution. The specs for the Hantek CC-65 don't really do it, other than price. Suggestions?
  10. enl

    DS18B20 temperature interpretation

    I am not sure what you are trying to ask, or what processor you are working with, but it appears that you don't have a good understanding of fixed point representations The value from the DS18B20 is a signed (2's complement) fixed point, 16 bit value. Cutting off the last four bits using a right shift that shifts zeros in to the left removes the sign. The shift can be done so as to preserve the sign by using the appropriate arithmetic right shift (arithmetic right shift RRA in assembler on the MSP430, or right shift operator in C on CSS). This will give an integer in 16 bit 2's complement. The rounding will ALWAYS be the floor (truncate to smaller value; round down) operation. To get round towards zero, you can use a condition such as (in C): if (t<0) t+=16; t=t>>4; or t=t>>4; if (t<0) t++; to do the job. If you want 'conventional' (grammar school) rounding (round down for the fraction <1/2, up for fractions >=1/2), then t+=8; t=t>>4; would be the cannonical way. If you want symmetrical rounding such that if the fraction of |t| < 1/2 is toward zero, and if hte fraction of |t|>=1/2, round away from zero, then, again, the easiest way is a condition: if (t<0) {t+=7;} else {t+=8;} Really, you need to know the desired behaviour. There are a lot of reasons why the default action is desirable (always round to negative infinity), in particular because then each count represents a range of one degree, rather than the range for zero being two degrees.
  11. Depending on the flash unit, the max current during charge may be quite high, 5A or more, judging by my Vivitar. The LM317 will current limit (the exact value depends on the version and manufacturer of the device), and the supply you are sourcing the LM317 from may also limit current. If the LM317 isn't warming up, it is likely the supply, not hte regulator. Another possibility is that the supply for the lm317 isn't high enough voltage for the regulator to do its job. It is not low drop out, and the max current goes down as the drop across the regulator goes down. Again, the exact voltage depends on the version, but typical is 1A max at 2V (from the onSemi data sheet) and a 2.5 input-to-output for the rater 1.5A output.
  12. enl

    Installing MSP432 broke MSP430

    Could you tell us the issue so that others can avoid it, or recognize it when a mistake is made?
  13. "if (bar[0]==NULL)" won't look at the pointer value, but instead the memory the pointer references, so that is right out, unless you want to know if the parameter is an empty string (only the null terminator) "if (bar == NULL)" should work, in particular if you explicitly pass NULL in since you are comparing a value to itself, as should "if (!bar)", since NULL should be 0. I just checked both (using gcc on a windoze machine) and they work as expected, so I can offer no insight as to why you would have a problem. I would suspect that you are seeing a symptom of some other issue than pointer comparison.
  14. enl

    20170311 - Upgrade

    In my first reply to the "true random number" thread, the last code block gave weird behaviour. The code editor opened, but refused to close. The code shows in a code block, but, when editing the post, the block can not be selected and acts like regular text.
  15. enl

    True random numbers

    (continued, due to editor throwing a fit on last code block in previous post) Your example: ( {1839765.71, 1839765.79} ) ... But only move the last digit (from 1 to 8) Presuming that you mean the last digit is selected from [1, 2, ..9], could be written as randomd(1839765.71,1839765.80,9); Again, note that the randomd() function DOES NOT include the right endpoint, so b is one least count greater in the function call than in your example. If you want the upper bound included, the function gets an n-1 for the division in offset.