Help me spot my mistake?

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Schematic attached.

 

This is a simple break out board for a Attiny10 with a FET on board to switch a load.  The FET is a DMN1019USN and the datasheet is also attached.

 

I'm powering with a single 3.7V battery.

 

The Attiny is running a basic blink program.  I can confirm with a multimeter that the PB2 pin is alternating between high and low, as expected.

 

However, when I measure between VCC and the FET drain, I do not see the expected "blinking" 3.7V from the battery.  Instead I see ~70mV.

 

What have I done wrong?

Attachment(s): 

Last Edited: Thu. Apr 6, 2017 - 09:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What happens at pin at pin 4? It is pulsating? If yes then the FET is not wired correctly, if not then maybe your code (should post it) or the micro are wonky.

 

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pin 4 is PB2

 

I can confirm with a multimeter that the PB2 pin is alternating between high and low, as expected.

By "pulsating" do you not mean blinking from high/low as I'd expect on that pin??  Why would that indicate the FET isn't wired right?  Sorry, I must be missing your point.

Last Edited: Thu. Apr 6, 2017 - 09:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's the code... I just borrowed some guy's Attiny10 blink program:

 

;
; tinyblink
; Blinks an LED on pin 4 (PB2)
;

.DEVICE ATtiny10

; variables
.EQU delayMult1 = 0xff ; the delay is delay3*delaymult2*delaymult1
.EQU delayMult2 = 0xff
.EQU delayMult3 = 0x2d

.CSEG ; code section
.ORG $0000 ; the starting address
main:
	; set up the stack
	ldi r16, high(RAMEND)
	out SPH, r16
	ldi r16, low(RAMEND)
	out SPL, r16

	; set clock divider
	ldi r16, 0x00 ; clock divided by 1
	ldi r17, 0xD8 ; the key for CCP
	out CCP, r17 ; Configuration Change Protection, allows protected changes
	out CLKPSR, r16 ; sets the clock divider

	; initialize port
	ldi r16, 1<<PB2 ; sets pin 4 (PB2) to putput
	out DDRB, r16 ; data direction
	ldi r16, 0x00 ; sets all pins low
	out PORTB, r16

	; nop for sync
	nop

loop:
	; turn on and delay
	ldi r16, (1<<PB2)
	out PORTB, r16
	rcall delay

	; turn off and delay
	ldi r16, 0x00
	out PORTB, r16
	rcall delay
	rjmp loop

delay:
	; not really needed, but keep r16-r18
	push r16
	push r17
	push r18

	ldi r16, delayMult1
	ldi r17, delayMult2
	ldi r18, delayMult3

	; start delay loop
delayLoop:
	subi r16, 1 ; subtract 1
	sbci r17, 0 ; if r16 was 0, subtract 1
	sbci r18, 0 ; if r17 was 0, subtract 1
	brne delayLoop ; while r18 is not 0, loop
	; end delay loop

	pop r18
	pop r17
	pop r16
	ret

Fixed register pops-JS

Last Edited: Fri. Apr 7, 2017 - 08:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By "pulsating" do you not mean blinking from high/low as I'd expect on that pin??

Yes.

.DEVICE ATtiny10

Out of curiosity which assembler are you using? Haven't seen the above for very long time. If you are using an old assembler or Studio then most likely it is using the ancient, never released?? Tiny10 (8 pins) definitions which are NOT the same for the new, 6 pin, ATtiny10.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using Studio 7.  The code, however, is just some random snippet I found on the Internet.

 

Anyway, you won't believe this (or maybe you will)... twice today I've been burned by faulty wires!  Same as my last post, the problem came down to a wire with (presumably) broken copper.  I think I'm just going to throw this spool out.

 

So this is working as expected.  Sorry to waste your time and thanks for your assistance.

 

ps.  it wasn't easy to spot.  When I tested the wire, it seemed to be fine.  That's because when I bent the wire to more easily touch the leads of the meter, the "break" would reconnect and it would seem fine.  Then when I'd let the wire go and hook it up to the LED, it wouldn't work.  I'd test at the LED and get nothing.   Finally I tested what I should have earlier, and put the leads directly to the FET (difficult due to tiny size) and that's when I realized it had to be the wire.  Tested more and confirmed.  Bent = good, straight = bad.  Yeesh.

 

pps.  I just realized this wasn't even my wire!  These were Molex pre-crimped leads I bought from Digikey just last month :(

Last Edited: Thu. Apr 6, 2017 - 09:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should POP in order R18, R17, R16.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ront1234 wrote:

You should POP in order R18, R17, R16.

 

Sharp eyes.  Points to you.  I've been burned by that more than once myself.

 

S.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Assemblers should have a function, where you mark a block, and registers that change within gets pushed and poped :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:

Assemblers should have a function, where you mark a block, and registers that change within gets pushed and poped :)

 

Unless it is the particular function of that assembler to change a particular register.

In that case, the College of Cardinals is irrelevant.  ;-)

S.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then don't mark the code with those ;)  (easier said than done I know)

I was more thinking about ISR etc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:

Then don't mark the code with those ;)  (easier said than done I know)
I was more thinking about ISR etc.

 

{8:-P}--

Even ISRs have work to do.  S.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
Assemblers should have a function, where you mark a block, and registers that change within gets pushed and poped :)

If you want a  tool to do that kind of stuff for you - it is called 'C' !!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that PB2 is driving a mosfet gate with a capacitance in the order of 2.4nF.

 

If you are blinking at high frequency, 2.4nF will have a fairly low impedance, and then PB2 cannot deliver the needed current to charge or discharge the gate. That current could be in the order of amperes.

 

Lower your frequency or put a mosfet driver between PB2 and the mosfet

 

Its also a good idea to add a resistor between PB2 and gate to limit load of PB2, if you drive a mosfet directly from PB2.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But the funny part is that C can't keep track of C ;)

 

ok this is a side track , so I'm out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Took the liberty of fixing the register pops in case someone else comes across the code and uses it.

 

oops looks like 2 of us edited the code. wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Fri. Apr 7, 2017 - 09:09 PM