Sitemize Hoşgeldiniz sitemizin kuruluş sebebi Eğitim Öğretim Bilgilendirme amaçlıdır Site içerik ve kaynalar Çeşitli Web Sitelerinden Derlenmişolup Teylif Hakları Çerçevesinde Korunuyor Olabilir Şayet bugibi durumlarda lütfen Site Yönetimiyle İrtibata geçiniz Saygılar Hikmet TURNA

2009

Serial Port Flash Loader for 8-Pin Z8F Zilog Encore(XP)

One major problem for the ZiLOG 8-pin mcu's is that it needs an expensive usb smart cable in order for the program to be 'flashed'/'burned' to their memory. This application aims to address this problem, by using a common serial port for flash loading (reading and erasing as well) instead of using an expensive tool.



For now,it's only tested with 8-pin Z8F042A. Hopefully in the future, it can also support other ZiLOG MCUs, not only these 8-pins (those 20- and 28-pins should be easier to program).

download: Flash Loader for 8-Pin Z8F.rar

forum link for project progress: Serial Port Flash Loader for 8-Pin Zilog MCUs

update(123009):
already tested with 8-pin z8f0423 and 28-pin z8f082a (yes, soic-28 also)

update(010110):
Win32 Executable verion: Flash Loader for 8-Pin Z8F (WIN32 Executable).rar
it only requires msvcp90.dll - most Win32 OS already have this; if not yet installed, it can be downloaded from Microsoft.



Python (pseudo) Compiler for PIC12/PIC16 Microcontrollers

It uses pyastra (python assembler translator) and gpasm assembler.
The PyQt GUI has a QScintilla-based editor for easy editing of the python scripts to be compiled.

main.py : (compatible with Portable Eric 4 Python IDE)
 #################################  
# Python (pseudo) Compiler for PIC12 and PIC16 devices
# using pyastra and gpasm
# PyQt GUI by yus
#################################

import sys, os
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.Qsci import QsciScintilla, QsciLexerPython

class ScriptEditor(QsciScintilla):
def __init__(self):
QsciScintilla.__init__(self)
self.filename = None
self.filedialog = QFileDialog()
# font
font = QFont()
font.setPointSize(9.5)

# Choose python lexer
lexer = QsciLexerPython()
lexer.setDefaultFont(font)
self.setLexer(lexer)

# Folding visual : we will use boxes
self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
# Braces matching
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
# Editing line color
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor(200, 240, 200))
# line numbers
self.setMarginWidth(0, QFontMetrics(font).width( "00000" ) )

def open(self):
self.filename = self.filedialog.getOpenFileName(None,
'Open Python Script', '.\\',
'python script(*.py);;text file(*.txt);;All files (*)', QString())
try:
f = open(self.filename)
self.setText(f.read())
f.close()
except:
print 'unable to open script.'

def save(self):
if self.filename == None:
self.save_as()
else:
try:
f = open(self.filename, "w")
f.write(str(self.text()))
f.close()
except:
print 'file not save.'

def save_as(self):
self.filename = self.filedialog.getSaveFileName(None,
'Save Python Script', '.\\',
'python script(*.py);;;text file(*.txt);;All files (*)', QString())
if self.filename != None:
self.save()

def get_filename(self):
return self.filename
class AppWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle('PIC12-PIC16 Python Compiler ( PyQt, PyAsTra and GPASM ) - yus ')
#self.setMinimumSize(700, 320)
#self.move(20, 20)

self.editor = ScriptEditor()
self.open_btn = QPushButton('Open')
self.save_btn = QPushButton('Save As')
self.device_label = QLabel('Select Device:')
self.status_info = QLabel('Select or create a python script first')
self.device_cbox = QComboBox()
self.compile_btn = QPushButton('Compile Script')
self.compile_btn.setEnabled(False) # initially disabled until a script is opened

self.editor_area = QDockWidget('(pic script here)')
self.editor_area.setWidget(self.editor)
self.addDockWidget(Qt.TopDockWidgetArea, self.editor_area)

self.output_info = QTextEdit()
self.output_info.setReadOnly(True) # read only information
self.output_info.setTextColor(Qt.darkBlue)
self.output_info_widget = QDockWidget('Output Information')
self.output_info_widget.setWidget(self.output_info)
self.addDockWidget(Qt.BottomDockWidgetArea, self.output_info_widget)

file_tbar = QToolBar()
file_tbar.addWidget(self.open_btn)
file_tbar.addWidget(self.save_btn)
compile_tbar = QToolBar()
compile_tbar.addWidget(self.device_label)
compile_tbar.addWidget(self.device_cbox)
compile_tbar.addWidget(self.compile_btn)

self.addToolBar(file_tbar)
self.addToolBar(compile_tbar)

self.status = QStatusBar()
self.status.addWidget(QLabel('\t')) # dummy widget
self.status.addWidget(self.status_info, 1)
self.setStatusBar(self.status)

self.update_device_list()
self.connect(self.save_btn, SIGNAL('clicked()'), self.save_script)
self.connect(self.open_btn, SIGNAL('clicked()'), self.open_script)
self.connect(self.compile_btn, SIGNAL('clicked()'), self.compile_script)

def open_script(self):
self.editor.open()
fname = str(self.editor.get_filename())
self.editor_area.setWindowTitle(fname)
if fname != 'None':
self.compile_btn.setEnabled(True)
def save_script(self):
self.editor.save_as()
fname = str(self.editor.get_filename())
self.editor_area.setWindowTitle(fname)
if fname != 'None':
self.compile_btn.setEnabled(True)
def compile_script(self):
self.editor.save() # save changes in the script before compiling
script = str(self.editor.get_filename())
device = str(self.device_cbox.currentText())
# PyAstra (python assymbly translator)
pyastra_command = '.\\pyastra_console.py -p'+device[3:] + ' -S --compile ' + script
msg = ' from pyastra console :\n'
try: # clean/delete previous output files
for ext in ('asm', 'hex', 'lst', 'cod'):
os.remove(script[:-2] + ext)
except:
pass #print 'one or more files not found'
try:
msg += os.popen(pyastra_command).read() # execute pyastra console
self.output_info.setText(msg) #pyastra.py info
except:
self.output_info.append('Error occured while translating the python script')
if msg.find('Program memory usage')>0:
# assemble the generated asm file using gpasm.exe
self.output_info.append('---------------\nExecuting gpasm.exe....')
file_asm = '%s'%self.editor.get_filename()
file_asm = file_asm[:file_asm.find('.py')] + '.asm'
#self.output_info.append( os.popen('.\\gpasm\\gpasm -v').read() ) # show gpasm version
msg = os.popen('.\\gpasm\\gpasm -I .\\gpasm\\header '+file_asm).read()
self.output_info.append(msg)
self.output_info.append('Finished.')
self.status_info.setText('Done')
else:
self.status_info.setText('Please verify the script')

def update_device_list(self):
for root, dirs, files in os.walk('.\\pyastra\\ports\\pic14\\procs'):
for name in files:
device = str(name)
if device[:1]=='1' and device.find('.pyc')<0 and device.find('i')<0:
device = device[:device.find('.')]
self.device_cbox.addItem('pic'+device)
self.device_cbox.setCurrentIndex(127) # initially set to PIC16F876A

if __name__ == '__main__':
app = QApplication(sys.argv)
form = AppWindow()
form.show()
sys.exit(app.exec_())




Complete Eric4 project : Python for PIC.rar
* already includes pyastra and gpasm

note: Python programming language is really NOT intended for platform/devices with very limited resources, such a microcontroller with a very small memory. For now, C language is still the widely used in microcontroller programming.

forum link: Python Compiler for PIC MCUs



This is NOT considered as an oscilloscope yet. It's just a preparation of making a real PIC18F USB-based oscilloscope. For my initial testing, I used my PIC18F and PyUSB demo, same hardware and firmware for the 18F2550. The only difference is in the GUI, instead of PyQt QDial, I use PyQwt PlotCurve widget.

the Python script: (compatible with my Portable Eric 4 Python IDE (v2))
 #################################  
# USB-based oscillpscope (beta)
# using pyUSB and PyQt/PyQwt
#################################

import sys, usb
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.Qwt5 import *
from PyQt4.Qwt5.anynumpy import *

class UsbPic:
def __init__(self, vendor_id, product_id):
busses = usb.busses() # enumerate busses
self.handle = None
for bus in busses:
devices = bus.devices
for dev in devices:
if dev.idVendor==vendor_id and dev.idProduct==product_id: # device matches
self.dev = dev
self.conf = self.dev.configurations[0]
self.intf = self.conf.interfaces[0][0]
self.endpoints = []
for endpoint in self.intf.endpoints:
self.endpoints.append(endpoint)
return

def open(self):
if self.handle:
self.handle = None
try:
self.handle = self.dev.open()
self.handle.detachKernelDriver(0)
self.handle.detachKernelDriver(1)
self.handle.setConfiguration(self.conf)
self.handle.claimInterface(self.intf)
self.handle.setAltInterface(self.intf)
return True
except:
return False

def write(self, ep, buff, timeout = 100):
try:
return self.handle.interruptWrite(ep, buff, timeout) #return bytes written
except:
return 0
def read(self, ep, size, timeout = 100):
try:
return self.handle.interruptRead(ep, size, timeout) # return data read
except:
return []
def getDeviceName(self):
return self.handle.getString(2, 40)

class AmplitudevsTime(QwtPlot):
def __init__(self):
QwtPlot.__init__(self)
self.setTitle("<font size=1 color=darkblue>Potentiometer Position ( 8-bit ADC value )</font>")
self.setCanvasBackground(Qt.black)
#grid
grid = QwtPlotGrid()
#grid.enableXMin(True)
#grid.enableYMin(True)
grid.setMajPen(QPen(Qt.darkGreen, 0, Qt.DotLine))
grid.setMinPen(QPen(Qt.darkGreen, 0 , Qt.DotLine))
grid.attach(self)
# x-axis
self.setAxisTitle(QwtPlot.xBottom, "<font size=1 color=darkred>time (seconds)</font>")
self.timerange = arange(0.0, 60, 0.2) #60 seconds, 200 ms interval
self.amplitudes = zeros(len(self.timerange), Float)
# curve
self.amplitude_plot = QwtPlotCurve('Amplitude')
self.setAxisScale(QwtPlot.yLeft, 0, 255) #amplitude range : 0 to 255
self.setAxisScale(QwtPlot.xBottom, 0, 60) #time range: 0 to 60 seconds
self.amplitude_plot.setPen(QPen(Qt.yellow))
self.amplitude_plot.attach(self)

def updatePlot(self, new_value=0):
# shift amplitude array left and assign new value to z[n-1].
self.amplitudes = concatenate((self.amplitudes[1:], self.amplitudes[:1]), 1)
self.amplitudes[-1] = new_value
self.amplitude_plot.setData(self.timerange, self.amplitudes)
self.replot()

class MyForm(QDialog):
def __init__(self, parent = None):
super(MyForm, self).__init__(parent)
self.setWindowTitle("USB-based Oscilloscope (Beta) - pYUSb + PIC18F2550")
self.setMinimumSize(560, 300)
# create widgets/controls
self.connect_btn = QPushButton('Connect')
self.toggle1_btn = QPushButton('Toggle LED1')
self.toggle2_btn = QPushButton('Toggle LED2')
self.status_label = QLabel('press "Connect" button')
self.update_timer = QTimer()

self.display = AmplitudevsTime()

layout = QGridLayout()
layout.addWidget(self.display, 0, 0, 10, 15)
layout.addWidget(self.toggle1_btn, 2, 15)
layout.addWidget(self.toggle2_btn, 2, 16)
layout.addWidget(self.connect_btn, 7, 15)
layout.addWidget(self.status_label, 4, 15, 2, 2)
self.setLayout(layout)
# widgets initial condition
self.toggle1_btn.setEnabled(False)
self.toggle2_btn.setEnabled(False)
# signals
self.connect(self.connect_btn, SIGNAL("clicked()"), self.DeviceConnect)
self.connect(self.toggle1_btn, SIGNAL("clicked()"), self.toggleLED1)
self.connect(self.toggle2_btn, SIGNAL("clicked()"), self.toggleLED2)
self.connect(self.update_timer, SIGNAL("timeout()"), self.updateDisplay)

def DeviceConnect(self):
self.device = UsbPic(0x04d8, 0x0204) # Microchip Vendor ID and Product ID
if self.device.open():
self.toggle1_btn.setEnabled(True)
self.toggle2_btn.setEnabled(True)
self.update_timer.start(200) # update every 200ms
self.status_label.setText('Connected to:\n %s' %self.device.getDeviceName())
else:
self.toggle1_btn.setEnabled(False)
self.toggle2_btn.setEnabled(False)
self.update_timer.stop()
self.status_label.setText('Warning:\n No Device Found!')
def toggleLED1(self):
self.device.write(1, [0x80], 1000)
def toggleLED2(self):
self.device.write(1, [0x82], 1000)
def updateDisplay(self):
self.device.write(1, [0x81])
byteread = self.device.read(0x81, 64)
if len(byteread)>1:
self.display.updatePlot(byteread[1])

if __name__ == "__main__":
app = QApplication(sys.argv)
form = MyForm()
form.show()
sys.exit(app.exec_())

Right now, my problem is on the 18F2550 side. I still don't know how to use both the USB and ADC interrupts together. My first modification on PIC's firmware was no success. When I enabled the ADC interrupt routine, the whole program response slows down. I still have to read properly the datasheet(plus application notes), and ask for help of the 'masters'. What I'm currently doing on the code is reading a single byte of ADC value every 200ms (very slow!). From what I've understand, the PIC can (it should) send 64 bytes for every USB interrupt read request. I don't know how fast it is, but it will surely improve the PIC18F USB-based oscilloscope.








Here are a power amplifier with TDA2009A integrated circuits produced by 10 +10 W stereo amplifier (see figure). As a result of ASIC, making her the production becomes very simple, the performance is not bad.



Her main performance characteristics in the table below.


Power Supply Voltage: DC 8-24V/1-2A

Power Output:

  1. 10W RMS / channel, 4 ohm load, 24V/DC power;

  2. 6W RMS / channel, 8 ohm load, 24V/DC power;

  3. 4W RMS / channel, 4 ohm load, 12V/DC power.



S/N: >75dB/10W output

Frequency response: 10Hz-50kHz,-3dB

Gain: 36dB

Input Level: 100mV Full output power



Schematic and Prototype:










Principle and production elements:


C1, C2 as the input capacitor, C10, C11 for the output capacitor. C6, C7 for the feedback capacitance. R1/R2, or (R3/R4) control the amount of feedback. Amplifier gain is equal to 1 + (R1/R2) = 68, or 37dB. C4, C5 for the power supply filter capacitor. The device maximum supply voltage of 28V. Hours of work required to add TDA2009A heat sink, and should pay attention to the power lines and then the choice of speaker wiring. Input should use shielded lines and as short as possible. Welding TDA200A not take too long when you pay attention, action to be fast, but if you want their full integration with the circuit board.





The order of 4 or sealed rear chamber bandpass system is essentially a system of watertight enclosures with the addition of an acoustic filter for the driver. The resulting system usually provides a lower cut-off frequency, the compromise that a larger case. The space can be reduced by two drivers in isobaric configuration.



4th-order bandpass systems generally show better able to handle the functions that the other major systems are considered. The transient response and is second only to the sealed enclosure systems, making it a good choice for subwoofer applications.



Since all output 4th order bandpass system is via the port, the largest diameter possible for the port area should be used to minimize noise from the port. The ports must be incinerated where possible, for the same reasons.







4th order Ssobaric Subwoofer Box Design



The 4th order bandpass system rarely allows a perfect bandpass response - there is usually an out-of-band noise present in the production. A notch filter can be used simply to reduce the noise as audible. Otherwise, a lowpass filter used in series with the driver, but the in-band response system may be affected if this approach is taken.



As the speaker sound 4th order band pass issued by the openings or ports on the port side of the box, the port noise inevitable.



This unwanted noise can be minimized by a notch filter and the largest diameter possible for the port of the area should definitely be used. Another option is to burn the ports of the 4th order bandpass room as this will certainly help to reduce unwanted extra from the subwoofer.



Mini SubWoofer Power Amplifier clik for detail



WOOFER / MID MODEL - 5MP60 / N


Specifications

Nominal Basket Diameter 5 "/ 125mm

Impedance 8 ohm

RMS Power 50 Watts

Program Power 100 Watts

Frequency response 50Hz - 12.0kHz

Sensitivity (1W/1m) 91dB

Voice Coil Diameter 1 "/ 25.8mm

BL Factor 6.4 N / A

Voice Coil Length 14 mm

Air Gap Height 6mm

X Damage (peak to peak) 20 mm

Magnetic Assembly Weight 2.2 lbs / 1.0 kg.

Edit Information

Diameter 5.28 "/ 134mm x 5.28" / 134mm

Bolt Circle Diameter 5.4 "/ 137mm

Baffle Cutout Diameter --

- Front Mount 4.72 "/ 120mm

Many of the 4 mounting holes

Volume displaced by driver, 019 m 3 / .5 liter

Total Depth 2.68 "/ 68mm

Net weight 2.64 lbs / 1.2 kg.

Weight 2.8 lbs / 1.27 kg.

Materials

Basketball aluminum diecast

Polypropylene cone

Rubber Surround

Voice Coil Wire Copper

Ferrite

Thiele-Small Parameters

Resonance Frequency (FS) 60 Hz

Impedance (Re) 5.33 ohms

Coil Inductance (Le) 0.4 mH

Mechanical Q (Qms) 1.604

Electrical Factor (Qes) .35

Total Q (Qts) .29

Comp. Equivalent Vol. (Vas) 35 FT3 / 9.8 Liter

Voice Coil Overhang (Xmax) 4.0mm

Reference yield 5%

Volume Displacement 34 cm3





The subwoofer is a subwoofer or a speaker to reproduce low frequencies, devotee of 20 Hz to 150 Hz electronic circuit diagram below shows the details of a scheme of the main amplifier TDA1516 22 watt in 4 ohm car subwoofer driver. This device is designed for an existing stereo amplifier, often requires adding another blow to the music of driving a subwoofer.



The amplifier uses BTL is a good and cheap ((Bridge Tied Load channels) 13-pin IC TDA1516 from Philips is now NXP Semiconductors), which may provide a small number of components and 22W at 4 ohm load voltage 12 volt car battery default.



The device consists of several parts: the name of the potentiometer, dual-linear motion potentiometers, 1/4W resistors, capacitors, electrolytic 25V, 63V Polyester capacitors, LED, 100 mA NPN transistor, dual BIFET Op-Amp, 24 W BTL car radio RCA audio input amplifier and two speakers 4 ohm or 8 ohm woofers in isobaric parallel wiring.







DIY 12 volt car project Subwoofer frequency low-pass filter circuit and BTL Amplifier TDA1516



The signals from the line outputs for stereo mixing amplifier input drive, and taking into account the level of the signal to the buffer and can be reversed IC1A phase SW1. Such control may be useful to the subwoofer in phase with the speaker of the existing car radio.



Then, a variable frequency 12dB/octave-pass low IC1B, the components of the Q1 and then you can pass the low frequency of 70 Hz or 150 Q2, R17 and C9 form a voltage stabilizer to facilitate access and filtering circuit to prevent track of the services given power at a low level positive.



LPF subwoofer and amplifier parts list:






Potentiometer

P1-10K

P2-22K



Resistor

R1, R4-1K

R2, R3, R5, R6-10K

R7, R8-100K

R9, R10, R13-47K

R11, R12-15K

R14, R15, R17-47K

R16 6K8

R18-1K5



Capacitor

C1, C2, C3, C6-4μ7 25V

C4, C5-68NF 63V

C7 33nF 63V

C8, C9 220μF 25V

C10 470nF 63V

C11 100nF 63V

C12 2200uF 25V



Diode

D1 LED Lamp



Transistor

Q1, Q2 BC547



IC

IC1-TL072 Op-Amp

IC2-TDA1516BQ Car Amplifier 24 Watt BTL



Switch

SW1-Toggle SPDT

SW2-Toggle SPDT



RCA Jack

J1, J2 RCA Audio Input



SubWoofer Drive Unit

4-ohm woofer driver or two 8 ohm woofers connected to Isobaric


MKRdezign

İletişim Formu

Ad

E-posta *

Mesaj *

Blogger tarafından desteklenmektedir.
Javascript DisablePlease Enable Javascript To See All Widget