cool article, interesting quote

In article , John Larkin wrote: [...]

I'm thinking about doing my own PTC thermistors for current limiting. The ones on the market all seem dreadful.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith
Loading thread data ...

"steve" schreef in bericht news: snipped-for-privacy@e56g2000cwe.googlegroups.com...

Nah, that can't be well written code. Well written code needs no maintenance and therefore needs no comments at all ;)

But I admit it often takes me while to understand what someone else has written. Seems that portable C is perhaps portable between platforms, but not between programmers.

;)

--
Thanks, Frank.
(remove 'q' and '.invalid' when replying by email)
Reply to
Frank Bemelman

But don't you do abstractions in your code? Even though I do write primarily in assembler, I build a "driver" for devices and pass "standard" units. A programmable power supply will have a driver that I set to 1.2(V), for instance. A delay line may be passed 120 (pS) or a clock generator 125(MHz). The driver then bit-bangs that into whatever the device needs. Different devices may be passed the same units, but bang the bits differently. AFAIC, that's abstraction, even though I'm banging the bits underneath.

That's an argument for making things as complex as possible. Job security! ;-)

Good thing I'm not a coder.

--
  Keith
Reply to
Keith

snip

If the software was company-critical the managers were either incompetent or too busy attending important meetings.

Reply to
Lanarcam

CS schools shouldn't teach coding at all; they should teach commenting.

I have debated programmers who are avidly anti-comment, and some use available utilities that strip comments from C programs. "The comments are always wrong, so they just confuse people."

One of the things I like about programming in asssembly is that the code density is low enough that there's lots of room for comments. Another thing I like is that programming in assembly slows you down enough that you actually have time to think.

John

.SBTTL INTERRUPT-SIDE MEASUREMENT SYSTEM

; TPU14 BEAMS US UP HERE AT THE 1113 HZ RATE (EVERY 898 USEC)

; WE ENTER WITH A CHANNEL PRESELECTED BY THE ANALOG MUX. WE THEN... ; ; TRIGGER THE ADC, READ THE VALUE, SCALE IT, FILTER IT, AND POKE ; IT INTO THE 'ANNIE' DATA TABLE ; ; DO AN 8-WAY DISPATCH TO FUNCTION BLOCKS. EACH IS RUN 139 TIMES/ ; SECOND AND MUST FINISH IN LESS THAN 800 USEC ; ; PHASE FUNCTION RUNTIME, USEC ; ===== =========================== =============== ; 0 COMPUTE TEMPERATURE 750 (ALL IN 'AUTO') ; 1 SAFETY CHECKS 560 ; 2 PID CONTROL 330 .. 400 ; 3 HEATER DRIVE 360 ; 4 LOCAL DISPLAY 140 .. 260 ; 5 MASHER LOOP 200 .. 340 ; 6 WATCHDOG TIMER / STATUS LED 190 .. 380 ; 7 LOWPASS FILTER TEMPERATURE 380 ; ; BEFORE WE EXIT THE IRQ, WE SELECT THE NEXT MUX CHANNEL FOR ; NEXT TIME THROUGH. NOTE THAT MUX CHANNELS ARE SCANNED NON- ; SEQUENTIALLY... SEE 'MUXCOD:' FOR THE PATTERN.

.SBTTL . 'TVEC' : INTERRUPT ENTRY

TVEC: BSET.B # 7, PORTF.W ; PULL UP TP4 AS IRQ TIMING FLAG

PUSH ; SAVE ALL REGISTERS

MOVE.W CISR.W, D1 ; READ ALL TPU INTERRUPT FLAGS CLR.W CISR.W ; THEN CLEAR THEM

.SBTTL . A/D CONVERSION

; THE MUX IS ALL SET UP AND SETTLED FROM LAST IRQ, SO JUST PRONG ; THE A/D CONVERTER:

MOVE.W D0, ADC.W ; TRIGGER THE ADC MOVE.W # 36, D7 ; LOAD TIMEOUT AND ASLEEP: NOP ; WAIT 20 MICROSECONDS DBF D7, ASLEEP ; FOR THE ADC TO FINISH

CLR.L D0 ; (CLEAN HIGH ADC DATA THINGIE) MOVE.W ADC.W, D0 ; READ THE ADC : UNSIGNED

12-BIT DATA ; GOES INTO D0[15..4]

.SBTTL . SAMPLE FILTERING AND SCALING

; THE RAW ADC DATA (IN D0) IS SCALED 0..FFF0h FOR 0..+5V, ; WITH SUITABLE ADJUSTMENT FOR PREAMP GAINS. WE'LL LOWPASS ; FILTER THIS IN 32-BIT FORM, THEN CONVERT TO ZFORM ENGR UNITS.

GLITCH: MOVE.W ARCH.W, D1 ; GET SCANNER INDEX ANDI.W # 7, D1 ; AND CLIP MOVEA.W D1, A3 ; COPY THE CHANNEL INDEX ADDA.W # MUXCOD, A3 ; AND OFFSET INTO THE MUX TABLE

MULU.W # FANNIE, D1 ; MAKE A TABLE INDEX IN 'D0' ADDI.W # ANNIE, D1 ; AIM INTO ANALOG DATA TABLE MOVEA.W D1, A0 ; AND COPY TO A POINTER...

SWAP.W D0 ; MOVE ADC DATA INTO HIGH D0 WORD LSR.L # 2, D0 ; AND DIVIDE BY 4... ; SCALING BECOMES 4000:0000h == +5V

TST.W INIT.W ; IN POWERUP PHASE, MAKE ALL CHANNELS BNE.S FROGGY ; FAST TO PRECHARGE FILTERS

TST.B (A3) ; CHECK MUXTAB 'FAST FILTER' FLAG BMI.S FROGGY ; IF SET, USE FAST FILTER

JSR LOWPAS.W ; HERE, USE THE SLOW LOWPASS FILTER BRA.S TOAD

FROGGY: JSR LOWFAS.W ; OR HERE, USE THE FASTER ONE. ; NOW FLOAT THE FILTERED ADC DATA AND SCALE TO ENGR UNITS...

TOAD: MOVE.L LPF4(A0), D6 ; COPY LPF DATA INTO ZL

BPL.S SCRUB ; CAUTION: WE ASSUME DATA IS POSITIVE, CLR.L D6 ; BUT NEGATIVE GLITCHES CAN HAPPEN.

SCRUB: CLR.L D5 ; AND NUKE ZH. NOW +5V == 0.25 Z-UNITS ; EG, Z = VOLTS/20

MOVE.W ARCH.W, D0 ; RECOVER SCAN INDEX ANDI.W # 7, D0 ; MOD EIGHT

ASL.W # 3, D0 ; * 8 FOR Z-TYPE INDEX ADD.W # GAINS, D0 ; AIM INTO 'GAIN FACTORS' LIST MOVEA.W D0, A6 ; AND AIM Z-POINTER AT SCALER

ZMUL ; - SCALE ADC DATA TO WHATEVERS -

MOVE.L D5, Z(A0) ; STASH ADC DATA MOVE.L D6, Z+4(A0) ; IN ANALOG DATA BLOCK.

; SELECT A MUX CHANNEL FOR NEXT TIME:

MEX: MOVE.W ARCH.W, D0 ; FETCH THE CHANNEL SCANNER ADDQ.W # 1, D0 ; + 1 FOR NEXT CHANNEL ANDI.W # 7, D0 ; TRUNK MOD8 FOR MUX LOGIC

ADDI.W # MUXCOD, D0 ; INDEX INTO THE MUX CONTROL MOVEA.W D0, A0 ; TABLE

MOVE.B (A0), D0 ; SNAB MUX CODE FROM TABLE ORI.B # B7, D0 ; - KEEP THE TP4 SCOPE BIT HIGH - MOVE.B D0, PORTF.W ; LOAD MUX FOR NEXT PASS.

Reply to
John Larkin

Somebody should make some nice IC current limiters, sort of a zero-volt regulator with a resistor-programmable current limit, thermal limit of course, nice ESD bahavior. It's an obvious winner.

John

Reply to
John Larkin

In both cases, the managers weren't programmers, so had little or no visibility as to what was going on, or actual progress. How could they? They just trusted experienced, professional, degreed programmers, who seemed to be always 90% done.

John

Reply to
John Larkin

I have quite a bit of sympathy for this viewpoint (where "comments" includes most supporting documentation, including flowcharts, which I positively despise). I always aim to make the (C) code so transparent as to need little or no comments - if there are comments, they're short, and associated with the code. I have indeed worked with legacy code where the coders had jumped straight in to tweaking the code, and not updated any of the supporting design documents - which did indeed confuse people. Wrong comments are worse than no comments - is the implementation wrong, or the comments?

The one time I *do* like monolithic comments is within interfaces (usually in the header file), where the interface is public, and the guts aren't. The implementation may be tweaked, but changes to the interface would probably need a meeting and a sign-off.

As I've said, I like to separate design from coding - especially when working in assembler. I do (most of) my thinking at the design stage, and code later. Designing in assembler is a recipe for disaster.

Steve

formatting link

Reply to
Steve at fivetrees

Somebody does. They're little 3-lead thingies in transisitor packages in the $1..$2 range from Digikey.

I just can't find my data sheets or part numbers, or remember how I found them...

...hang on, ask Digikey for "current sources" -- LM134, LM234, LM334.

Mel.

Reply to
Mel Wilson

Another shining example of why socialism always fails. :-/

Thanks, Rich

--
"We have met the enemy and he is us." - Pogo Possum
Reply to
Richard the Dreaded Libertarian

I once heard that potassium is very good for maintaining your electrolyte balance, so I got some "lite" salt, which is about half KCl. Possibly surprisingly, it seems to taste "saltier" than NaCl, so you can use less than you would with plain salt, which might be another benefit. :-)

It comes in a light blue cylinder about 2/3 the diameter of the dark blue ones, and sits right next to them on the grocery shelf.

Cheers! Rich

Reply to
Rich Grise

OK, but the 0.8 volts, 10 mA specs limit its utility a lot. I'd like a tenth of a volt drop maybe, and currents programmable to at least an amp maybe, a reasonably precise self-resetting fuse. As Ken says, the polyfuses are dreadful.

John

Reply to
John Larkin

Somewhat as expected, Jack Ganssle was quoted out of context. From his latest newsletter:

One of my talks at this month's Embedded Systems Conference got quite a bit of press coverage. EE Times ran this quote: "The use of C is really criminal; C will compile a telephone directory, practically. I guess we use C because we think debugging is fun."

The quote was, of course, taken out of context. In the talk I went on to say that the tools we use to build tremendously complex applications are inherently fragile. C gives us fantastic capabilities, but by itself it offers little to protect us from errors. *********************i=3; is a perfectly legitimate statement... but no human knows what it means. Only good processes, smart and engaged people, and the use of other, complementary, tools will tame the hydra of software complexity.

Reply to
Steve at fivetrees

Huh? Where do you get "0.8 volts"? It has voltage compliance up to 40V, as long as you keep the dissipation less than 400 mW.

But 10 mA does seem a little skimpy. ;-)

Cheers! Rich

Reply to
Rich Grise

Well, the 0.8 volts is in the spec. It's the "typical minimum" operating voltage at low currents. Actually, the typ-min operating volts is 1.0 at 1-5 mA, and not even specified at the abs max current of 10 mA. So the beast always drops 0.8 to maybe 1.0 or so. Not too cool for a current limiter.

National used to sell a PNP transistor with very tight beta specs, for use as a pure-beta current limiter. I did a beta-based current limiter once, based on a transistor and a selected base resistor, and sold it to NASA.

John

Reply to
John Larkin

I don' t think that was a good example of a "out of context" quote, more like he was expressing two different, conflicting thoughts, it would help if he spent some time crystallizing his thoughts before talking again.

Reply to
steve

How can context modify a statement as agressive as that? Sounds like damage control to me. In the next paragraph of the eetimes article, he compares C very unfavorably against Ada and Spark.

Too bad he's backing down, when he was right.

John

Reply to
John Larkin

1N5314
--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

In article , John Larkin wrote: [...]

I was actually refering to CPTCs but yes the polyfuse is dreadful too. Try taking one an connecting straight to a car battery. Many of them break if you do that.

The CPTCs have tol. of about +/- 100%

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

KCl tastes like aluminum foil. The fact is that the taste of salt is addictive. The more you use the more your taste wants. We stopped adding salt to food twenty years ago and never miss it, though some food prepared by others (ham is often a biggie) is inedible.

That stuff tastes like shit! Though...

--
  Keith
Reply to
Keith

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.