196
Messages
This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.
Messages - Scorpia
197
Hack a Day projects / Re: Graffiti wall
from memory all the webserver code did was read the files from an external website and then display them. but i could have got it wrong.
When i first saw the graffiti wall project because the lighting project has a 64 channel controller based on the led driver chip. so with some small mods i was hoping to have a web front end to the 64 channel board. but as with alot of my projects i moved on as im no good at coding. still interested though
198
Hack a Day projects / Re: Updated software
Im not sure how limiting the current pic24 is but if you were going to update it would you not look at going to the pic32?
im guessing theres not one thats pin compatible but might be worth a look.
The 2 main functions i was interested in allowed the website to interact with the board. i cant remember what they were called but if they were implemented it would allow the website to control i/o, read the sd card etc very easily.
as allways let me know if there are any updates to this
Peter
199
Bus Pirate Support / Re: Hardware I2C master and slave
looks like i missed out.
Code: [Select]
HiZ>i
Hack a Day Bus Pirate v2go
http://www.buspirate.com
Firmware v2.1-nightly
DEVID:0x04 0x47
REVID:0x30 0x03
CFG1:0xF9 0xDF
CFG2:0x3F 0x7F
HiZ>
200
Bus Pirate Support / Re: I2C, no ACK at random times
which gave me a good idea. can the pwm output keep outputting while switching to a diff mode?
the idea being that the bus pirate should be able to generate a osc freq to clock the chip while looking at it.
i know it wouldnt be that accurate but it seems like a good idea to me. maybe some common freq might be a good idea .
anyway i will pick up a couple of crystals tomorrow as i want to test this anyway as well as the ds2404 chip i have.
201
Bus Pirate Support / Re: I2C, no ACK at random times
Also being that most of the current buspirates cant use the hardware i2c routines (?) , maybe its worth trying to add some options to change the speed of the current routines.
is there an update to the current v2 software that i can grab that will tell me what type of chip i have. i am pretty sure i checked it under MPLAB and it was the earlier one but i am not sure right now.
Peter
202
DIY Life projects / Re: Free PCBs
this is something i would love to have a look at.
i would be happy to pay any shipping charges + whatever to get em to australia.
thanks again
Peter
203
Bus Pirate Support / Re: Bus Pirate v3: Beating the shortage
dont the 2 pins just get shorted when its in bootloader mode?
as for standard dementions for a case well i dont think there are any. it would be a matter of selectign a case and designing it for it.
im guessing seed could point you in the direction of a case that they can get.
204
Bus Pirate Support / Re: Bus Pirate v3: Beating the shortage
anyway just a thought
205
Bus Pirate Support / Re: Why PIC24J64GA002?
206
Bus Pirate Support / Re: Linux - Bootloader-Programmer
do you allready have a pic programmer? If so can you do a chip erase and verify that it is blank? if it is blank it should just be a matter of reloading the bootloader.
if you cant blank the chip then it becomes harder.

peter
207
Bus Pirate Support / Re: Bus Pirate v3: Beating the shortage
208
Bus Pirate Support / Re: Bus Pirate v3: Beating the shortage
is it worth putting both the tx and rx lights on for the fdti chip?
Also have you swapped the pgc and pgd pins around on the icsp header?
i havnt checked the schematic but are there any spare i/o on the pic. is it worth trying to put them out on an extra header for "future expansion" etc.
Peter
209
Bus Pirate Support / Re: which compiler
ok i have exported again with the config bits and as expected those errors are gone.
strange i would have expected that the bootloader would set any config bits required so that the main program wouldnt need the config bits.
ah well live and learn
Also if someone else has some different 1-wire chips that thay would like added im quiet happy to add them .
As for SVN access honestly i cant really see the point. the changes i am likely to make are very minor and few and far between i would think.
i dont have any other 1wire chips to test atm so i think that will be me for a little while.
210
Bus Pirate Support / Re: which compiler
fired up the bootloaded and imported. it seems to work but i got 2 extra verify errors other than the expected range, they are
Quote
Verify Error at 0xABFC should be: 0xFFFFFF but read: 0xF9DF
Verify Error at 0xABFE should be: 0xFFFFFF but read: 0x3F7F
since i cant see a way to attach a file. here is the modified 1wire.c source file
maybe you can add it to the sovn, hopefully save you 5 min work

Code: [Select]
/*
* This file is part of the Bus Pirate project (buspirate.com).
*
* One wire search code taken from here: http://www.maxim-ic.com/appnotes.cfm/appnote_number/187
*
* We claim no copyright on our code, but there may be different licenses for some of the code in this file.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
//abstraction for m_i2c_1.c
#include "m_1wire_213.h"
#include "1wire.h"
#include "base.h"
extern struct _modeConfig modeConfig;
//the roster stores the first OW_DEV_ROSTER_SLOTS 1-wire addresses found during a ROM SEARCH command
//these addresses are available as MACROs for quick address entry
#define OW_DEV_ROSTER_SLOTS 10 //how many devices max to store addresses as MACROs
struct _OWID{
// unsigned char familyID; //to lazy to do it right, for now...
unsigned char id[8];
// unsigned char crc;
};
struct _OWIDREG{
unsigned char num;
struct _OWID dev[OW_DEV_ROSTER_SLOTS];
} ;
struct _OWIDREG OWroster;
void DS1wireID(unsigned char famID);
unsigned char OWFirst(void);
unsigned char OWNext(void);
unsigned char OWSearch(void);
unsigned char OWVerify(void);
unsigned char docrc8(unsigned char value);
//because 1wire uses bit times, setting the data line high or low with (_-) has no effect
//we have to save the desired bus state, and then clock in the proper value during a clock(^)
static unsigned char DS1wireDataState=0;//data bits are low by default.
// global search state,
//these lovely globals are provided courtesy of MAXIM's code
//need to be put in a struct....
unsigned char ROM_NO[8];
unsigned char SearchChar=0xf0; //toggle between ROM and ALARM search types
unsigned char LastDiscrepancy;
unsigned char LastFamilyDiscrepancy;
unsigned char LastDeviceFlag;
unsigned char crc8;
void DS1wireReset(void);
//this function links the underlying library functions to generic commands that the bus pirate issues
//put most used functions first for best performance
void DS1wireProcess(unsigned char cmd, unsigned int numVal, unsigned int repeatVal){
static unsigned char c,j;
static unsigned int i;
static unsigned char devID[8];
switch(cmd){
case CMD_READ:
if(repeatVal==1){
bpWmessage(MSG_READ);
c=OWReadByte();
bpWbyte(c);
}else{
bpWmessage(MSG_READBULK);
bpWbyte(repeatVal);
bpWstring(" BYTES:x0Dx0A");
for(i=0;i<repeatVal;i++){
c=OWReadByte();
bpWbyte(c);
bpWstring(" ");
}
}
bpWBR;
break;
case CMD_WRITE:
bpWmessage(MSG_WRITE);
bpWbyte(numVal);
OWWriteByte(numVal);
bpWBR;
break;
case CMD_STARTR:
case CMD_START:
//bus reset
DS1wireReset();
break;
case CMD_BIT_READ:
c=OWReadBit();
bpWmessage(MSG_BIT_READ);
bpEchoState(c);
bpWstring(" *now input directionx0Dx0A");
break;
case CMD_BIT_CLK: //we use clock as the 1wire write slot, use _- to set data state
bpWstring("1WIRE ");
bpWbyte(repeatVal);
bpWstring(" WRITE BIT(S) (");
for(i=0;i<repeatVal;i++) OWWriteBit(DS1wireDataState);
bpEchoState(DS1wireDataState);
bpWline(")");
break;
case CMD_BIT_DATH://this also sets a bit direction variable that sets the bits that are clocked with ^
case CMD_BIT_DATL:
bpWstring("1WIRE WRITE BIT: ");
if(cmd==CMD_BIT_DATL){
DS1wireDataState=0;
bpEchoState(0);
}else{
DS1wireDataState=1;
bpEchoState(1);
}
bpWstring(" *next clock (^) will also have this valuex0Dx0A");
OWWriteBit(DS1wireDataState);
break;
case CMD_PRESETUP: //set the options avaiable here....
modeConfig.allowlsb=0;
modeConfig.allowpullup=1;
modeConfig.HiZ=1;//yes, always HiZ
break;
case CMD_SETUP:
OWroster.num=0;//clear any old 1-wire bus enumeration rosters
//-- Ensure pins are in high impedance mode --
SDA_TRIS=1;
//writes to the PORTs write to the LATCH
SDA=0; //B9 sda
bpWline("1WIRE routines Copyright (C) 2000 Michael Pearce");
bpWline("Released under GNU General Public License");
bpWline("1WIRE READY");
break;
case CMD_CLEANUP: //no cleanup needed...
break;
case CMD_MACRO:
if(numVal>0 && numVal<51){
numVal--;//adjust down one for roster array index
if(numVal>=OWroster.num){//no device #X on the bus, try ROM SEARCH (0xF0)
bpWstring("1WIRE MACRO: NO DEVICE #");
bpWdec(numVal);
bpWline(" ENUMERATED, TRY SEARCH ROM MACRO FIRST (0xF0)");
return;
}
//write out the address of the device in the macro
bpWstring("1WIRE ADDRESS MACRO ");//xxx WRITE BUS #X ID:
bpWdec(numVal+1);
bpWstring(": ");
for(j=0;j<8;j++){
bpWbyte(OWroster.dev[numVal].id[j]);
bpWstring(" ");
OWWriteByte(OWroster.dev[numVal].id[j]);
} //write address
bpWline(" ");
return;
}
switch(numVal){
case 0://menu
bpWline(" 0.Macro menu");
bpWline("Macro 1WIRE address");
//write out roster of devices and macros, or SEARCH ROM NOT RUN, TRY (0xf0)
if(OWroster.num==0){
bpWline(" NO DEVICES ENUMERTED, TRY (ALARM) SEARCH ROM FIRST");
}else{
for(c=0;c<OWroster.num; c++){
bpWstring(" ");
bpWdec(c+1);
bpWstring(".");
for(j=0;j<8;j++){bpWbyte(OWroster.dev[c].id[j]); bpWstring(" ");}
bpWstring("x0Dx0A *");
DS1wireID(OWroster.dev[c].id[0]); //print the device family identity (if known)
}
}
bpWstring("1WIRE ROM COMMAND MACROs:x0Dx0A 51.READ ROM (0x33) *for single device busx0Dx0A 85.MATCH ROM (0x55) *followed by 64bit addressx0Dx0A 204.SKIP ROM (0xCC) *followed by commandx0Dx0A 236.ALARM SEARCH (0xEC)x0Dx0A 240.SEARCH ROM (0xF0)x0Dx0A");
break;
//1WIRE ROM COMMANDS
case 0xec://ALARM SEARCH
case 0xf0: //SEARCH ROM
if(numVal==0xec){
SearchChar=0xEC;//use ROM ALARM SEARCH type
bpWline("1WIRE ROM COMMAND: ALARM SEARCH (0xEC)");
}else{//SEARCH ROM command...
SearchChar=0xF0;//use ROM SEARCH type
bpWline("1WIRE ROM COMMAND: SEARCH (0xF0)");
}
bpWline("Found devices at:");
bpWline("Macro 1WIRE address");
// find ALL devices
j = 0;
c = OWFirst();
OWroster.num=0;
while (c){
//the roster number is the shortcut macro
bpWstring(" ");
bpWdec(j+1);
bpWstring(".");
// print address
for (i = 0; i <8; i++){
bpWbyte(ROM_NO[i]);
bpWstring(" ");
}
bpWstring("x0Dx0A *");
DS1wireID(ROM_NO[0]); //print the device family identity (if known)
//keep the first X number of one wire IDs in a roster
//so we can refer to them by macro, rather than ID
if(j<OW_DEV_ROSTER_SLOTS){//only as many as we have room for
for(i=0;i<8;i++) OWroster.dev[OWroster.num].id[i]=ROM_NO[i];
OWroster.num++;//increment the roster count
}
j++;
c = OWNext();
}
bpWstring("Found ");
bpWbyte(j);
bpWline(" devices.");
bpWstring("The first ");
bpWdec(OW_DEV_ROSTER_SLOTS);
bpWline(" device IDs are available by MACRO, see (0).");
break;
case 0x33://READ ROM
DS1wireReset();
bpWline("1WIRE WRITE ROM COMMAND: READ (0x33) *for single device bus only");
OWWriteByte(0x33);
bpWline("1WIRE BULK READ 8 BYTES:");
for(i=0; i<8; i++){
devID[i]=OWReadByte();
bpWbyte(devID[i]);
bpWstring(" ");
}
bpWBR;
DS1wireID(devID[0]);
break;
case 0x55://MATCH ROM
DS1wireReset();
bpWline("1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address");
OWWriteByte(0x55);
break;
case 0xcc://SKIP ROM
DS1wireReset();
bpWline("1WIRE WRITE ROM COMMAND: SKIP (0xCC) *follow with command");
OWWriteByte(0xCC);
break;
default:
bpWmessage(MSG_ERROR_MACRO);
}
break;
default:
bpWmessage(MSG_ERROR_MODE);
}
}
void DS1wireReset(void){
unsigned char c;
c=OWReset();
bpWstring("1WIRE BUS RESET ");
if(c==0){
bpWline("OK");
}else{
bpWstring("ERROR: ");
if(c&0b1) bpWstring("*SHORT OR NO PULLUP ");
if(c&0b10) bpWstring("*NO DEVICE DETECTED ");
bpWstring("(");
bpWbyte(c);
bpWline(")");
}
}
void DS1wireID(unsigned char famID){
//some devices, according to:
//http://owfs.sourceforge.net/commands.html
#define DS2404 0x04
#define DS18S20 0x10
#define DS1822 0x22
#define DS18B20 0x28
#define DS2431 0x2D
switch(famID){//check for device type
case DS18S20:
bpWline("DS18S20 High Pres Dig Therm");
break;
case DS18B20:
bpWline("DS18B20 Prog Res Dig Therm");
break;
case DS1822:
bpWline("DS1822 Econ Dig Therm");
break;
case DS2404:
bpWline("DS2404 Econram time Chip");
break;
case DS2431:
bpWline("DS2431 1K EEPROM");
break;
default:
bpWline("Unknown device family ID");
}
}
//the 1-wire search algo taken from:
//http://www.maxim-ic.com/appnotes.cfm/appnote_number/187
#define TRUE 1 //if !=0
#define FALSE 0
//--------------------------------------------------------------------------
// Find the 'first' devices on the 1-Wire bus
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : no device present
//
unsigned char OWFirst()
{
// reset the search state
LastDiscrepancy = 0;
LastDeviceFlag = FALSE;
LastFamilyDiscrepancy = 0;
return OWSearch();
}
//--------------------------------------------------------------------------
// Find the 'next' devices on the 1-Wire bus
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search
//
unsigned char OWNext()
{
// leave the search state alone
return OWSearch();
}
//--------------------------------------------------------------------------
// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing
// search state.
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search
//
unsigned char OWSearch()
{
unsigned char id_bit_number;
unsigned char last_zero, rom_byte_number, search_result;
unsigned char id_bit, cmp_id_bit;
unsigned char rom_byte_mask, search_direction;
// initialize for search
id_bit_number = 1;
last_zero = 0;
rom_byte_number = 0;
rom_byte_mask = 1;
search_result = 0;
crc8 = 0;
// if the last call was not the last one
if (!LastDeviceFlag)
{
// 1-Wire reset
if (OWReset())
{
// reset the search
LastDiscrepancy = 0;
LastDeviceFlag = FALSE;
LastFamilyDiscrepancy = 0;
return FALSE;
}
// issue the search command
OWWriteByte(SearchChar); //!!!!!!!!!!!!!!!
// loop to do the search
do
{
// read a bit and its complement
id_bit = OWReadBit();
cmp_id_bit = OWReadBit();
// check for no devices on 1-wire
if ((id_bit == 1) && (cmp_id_bit == 1))
break;
else
{
// all devices coupled have 0 or 1
if (id_bit != cmp_id_bit)
search_direction = id_bit; // bit write value for search
else
{
// if this discrepancy if before the Last Discrepancy
// on a previous next then pick the same as last time
if (id_bit_number < LastDiscrepancy)
search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
else
// if equal to last pick 1, if not then pick 0
search_direction = (id_bit_number == LastDiscrepancy);
// if 0 was picked then record its position in LastZero
if (search_direction == 0)
{
last_zero = id_bit_number;
// check for Last discrepancy in family
if (last_zero < 9)
LastFamilyDiscrepancy = last_zero;
}
}
// set or clear the bit in the ROM byte rom_byte_number
// with mask rom_byte_mask
if (search_direction == 1)
ROM_NO[rom_byte_number] |= rom_byte_mask;
else
ROM_NO[rom_byte_number] &= ~rom_byte_mask;
// serial number search direction write bit
OWWriteBit(search_direction);
// increment the byte counter id_bit_number
// and shift the mask rom_byte_mask
id_bit_number++;
rom_byte_mask <<= 1;
// if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask
if (rom_byte_mask == 0)
{
docrc8(ROM_NO[rom_byte_number]); // accumulate the CRC
rom_byte_number++;
rom_byte_mask = 1;
}
}
}
while(rom_byte_number < 8); // loop until through all ROM bytes 0-7
// if the search was successful then
if (!((id_bit_number < 65) || (crc8 != 0)))
{
// search successful so set LastDiscrepancy,LastDeviceFlag,search_result
LastDiscrepancy = last_zero;
// check for last device
if (LastDiscrepancy == 0)
LastDeviceFlag = TRUE;
search_result = TRUE;
}
}
// if no device found then reset counters so next 'search' will be like a first
if (!search_result || !ROM_NO[0])
{
LastDiscrepancy = 0;
LastDeviceFlag = FALSE;
LastFamilyDiscrepancy = 0;
search_result = FALSE;
}
return search_result;
}
//--------------------------------------------------------------------------
// Verify the device with the ROM number in ROM_NO buffer is present.
// Return TRUE : device verified present
// FALSE : device not present
//
unsigned char OWVerify()
{
unsigned char rom_backup[8];
unsigned char i,rslt,ld_backup,ldf_backup,lfd_backup;
// keep a backup copy of the current state
for (i = 0; i < 8; i++)
rom_backup[i] = ROM_NO[i];
ld_backup = LastDiscrepancy;
ldf_backup = LastDeviceFlag;
lfd_backup = LastFamilyDiscrepancy;
// set search to find the same device
LastDiscrepancy = 64;
LastDeviceFlag = FALSE;
if (OWSearch())
{
// check if same device found
rslt = TRUE;
for (i = 0; i < 8; i++)
{
if (rom_backup[i] != ROM_NO[i])
{
rslt = FALSE;
break;
}
}
}
else
rslt = FALSE;
// restore the search state
for (i = 0; i < 8; i++)
ROM_NO[i] = rom_backup[i];
LastDiscrepancy = ld_backup;
LastDeviceFlag = ldf_backup;
LastFamilyDiscrepancy = lfd_backup;
// return the result of the verify
return rslt;
}
// TEST BUILD
static unsigned char dscrc_table[] = {
0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65,
157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220,
35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98,
190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255,
70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7,
219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154,
101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36,
248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185,
140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205,
17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80,
175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238,
50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115,
202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139,
87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22,
233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168,
116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53};
//--------------------------------------------------------------------------
// Calculate the CRC8 of the byte value provided with the current
// global 'crc8' value.
// Returns current global crc8 value
//
unsigned char docrc8(unsigned char value)
{
// See Application Note 27
// TEST BUILD
crc8 = dscrc_table[crc8 ^ value];
return crc8;
}
here is the output from the (240) macro with the new update
Quote
1-WIRE>(240)_
1WIRE ROM COMMAND: SEARCH (0xF0)
Found devices at:
Macro 1WIRE address
1.0x10 0x36 0x00 0x83 0x00 0x08 0x00 0x83
*DS18S20 High Pres Dig Therm
2.0x10 0xF1 0x00 0x83 0x00 0x08 0x00 0x99
*DS18S20 High Pres Dig Therm
3.0x28 0x6E 0x49 0x66 0x00 0x00 0x00 0x4D
*DS18B20 Prog Res Dig Therm
4.0x28 0x9E 0x45 0x15 0x00 0x00 0x00 0x3E
*DS18B20 Prog Res Dig Therm
5.0x04 0x9D 0x46 0x4A 0x00 0x00 0x00 0x81
*DS2404 Econram time Chip
Found 0x05 devices.
The first 10 device IDs are available by MACRO, see (0).
i hope this information helps someone. and if anyone knows how to fix those 2 verify errors it would be great
thanks
Peter