From: drowe67 Date: Tue, 1 Jul 2014 22:04:08 +0000 (+0000) Subject: mv to attic X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=82c317bfd009f1f72fc55c965897c84215bb978f;p=freetel-svn-tracking.git mv to attic git-svn-id: https://svn.code.sf.net/p/freetel/code@1731 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/attic/wispcar/COPYING b/attic/wispcar/COPYING new file mode 100644 index 00000000..d60c31a9 --- /dev/null +++ b/attic/wispcar/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/attic/wispcar/LICENSE b/attic/wispcar/LICENSE new file mode 100644 index 00000000..4b992c41 --- /dev/null +++ b/attic/wispcar/LICENSE @@ -0,0 +1,266 @@ +The TAPR Open Hardware License +Version 1.0 (May 25, 2007) +Copyright 2007 TAPR – http://www.tapr.org/OHL + +PREAMBLE + +Open Hardware is a thing - a physical artifact, either electrical or +mechanical - whose design information is available to, and usable by, +the public in a way that allows anyone to make, modify, distribute, and +use that thing. In this preface, design information is called +"documentation" and things created from it are called "products." + +The TAPR Open Hardware License ("OHL") agreement provides a legal +framework for Open Hardware projects. It may be used for any kind of +product, be it a hammer or a computer motherboard, and is TAPR's +contribution to the community; anyone may use the OHL for their Open +Hardware project. + +Like the GNU General Public License, the OHL is designed to guarantee +your freedom to share and to create. It forbids anyone who receives +rights under the OHL to deny any other licensee those same rights to +copy, modify, and distribute documentation, and to make, use and +distribute products based on that documentation. + +Unlike the GPL, the OHL is not primarily a copyright license. While +copyright protects documentation from unauthorized copying, modification, +and distribution, it has little to do with your right to make, distribute, +or use a product based on that documentation. For better or worse, patents +play a significant role in those activities. Although it does not prohibit +anyone from patenting inventions embodied in an Open Hardware design, and +of course cannot prevent a third party from enforcing their patent rights, +those who benefit from an OHL design may not bring lawsuits claiming that +design infringes their patents or other intellectual property. + +The OHL addresses unique issues involved in the creation of tangible, +physical things, but does not cover software, firmware, or code loaded +into programmable devices. A copyright-oriented license such as the GPL +better suits these creations. + +How can you use the OHL, or a design based upon it? While the terms and +conditions below take precedence over this preamble, here is a summary: + +* You may modify the documentation and make products based upon it. + +* You may use products for any legal purpose without limitation. + +* You may distribute unmodified documentation, but you must include the +complete package as you received it. + +* You may distribute products you make to third parties, if you either +include the documentation on which the product is based, or make it +available without charge for at least three years to anyone who requests +it. + +* You may distribute modified documentation or products based on it, if +you: + * License your modifications under the OHL. + * Include those modifications, following the requirements stated + below. + * Attempt to send the modified documentation by email to any of the + developers who have provided their email address. This is a good + faith obligation – if the email fails, you need do nothing more + and may go on with your distribution. + +* If you create a design that you want to license under the OHL, you +should: + * Include this document in a file named LICENSE (with the appropriate + extension) that is included in the documentation package. + * If the file format allows, include a notice like “Licensed under + the TAPR Open Hardware License (www.tapr.org/OHL)” in each + documentation file. While not required, you should also include + this notice on printed circuit board artwork and the product + itself; if space is limited the notice can be shortened or + abbreviated. + * Include a copyright notice in each file and on printed circuit + board artwork. + * If you wish to be notified of modifications that others may make, + include your email address in a file named “CONTRIB.TXT” or + something similar. + +* Any time the OHL requires you to make documentation available to +others, you must include all the materials you received from the +upstream licensors. In addition, if you have modified the +documentation: + * You must identify the modifications in a text file (preferably + named "CHANGES.TXT") that you include with the documentation. + That file must also include a statement like "These modifications + are licensed under the TAPR Open Hardware License." + * You must include any new files you created, including any + manufacturing files (such as Gerber files) you create in the + course of making products. + * You must include both "before" and "after" versions of all files + you modified. + * You may include files in proprietary formats, but you must also + include open format versions (such as Gerber, ASCII, Postscript, + or PDF) if your tools can create them. + +TERMS AND CONDITIONS + +1. Introduction +1.1 This Agreement governs how you may use, copy, modify, and +distribute Documentation, and how you may make, have made, and +distribute Products based on that Documentation. As used in this +Agreement, to "distribute" Documentation means to directly or indirectly +make copies available to a third party, and to "distribute" Products +means to directly or indirectly give, loan, sell or otherwise transfer +them to a third party. + +1.2 "Documentation" includes: + (a) schematic diagrams; + (b) circuit or circuit board layouts, including Gerber and other + data files used for manufacture; + (c) mechanical drawings, including CAD, CAM, and other data files + used for manufacture; + (d) flow charts and descriptive text; and + (e) other explanatory material. +Documentation may be in any tangible or intangible form of expression, +including but not limited to computer files in open or proprietary +formats and representations on paper, film, or other media. + +1.3 "Products" include: + (a) circuit boards, mechanical assemblies, and other physical parts + and components; + (b) assembled or partially assembled units (including components + and subassemblies); and + (c) parts and components combined into kits intended for assembly + by others; +which are based in whole or in part on the Documentation. + +1.4 This Agreement applies to any Documentation which contains a +notice stating it is subject to the TAPR Open Hardware License, and to +all Products based in whole or in part on that Documentation. If +Documentation is distributed in an archive (such as a "zip" file) which +includes this document, all files in that archive are subject to this +Agreement unless they are specifically excluded. Each person who +contributes content to the Documentation is referred to in this +Agreement as a "Licensor." + +1.5 By (a) using, copying, modifying, or distributing the +Documentation, or (b) making or having Products made or distributing +them, you accept this Agreement, agree to comply with its terms, and +become a "Licensee." Any activity inconsistent with this Agreement will +automatically terminate your rights under it (including the immunities +from suit granted in Section 2), but the rights of others who have +received Documentation, or have obtained Products, directly or +indirectly from you will not be affected so long as they fully comply +with it themselves. + +1.6 This Agreement does not apply to software, firmware, or code +loaded into programmable devices which may be used in conjunction with +Documentation or Products. Such software is subject to the license +terms established by its copyright holder(s). + +2. Patents +2.1 Each Licensor grants you, every other Licensee, and every +possessor or user of Products a perpetual, worldwide, and royalty-free +immunity from suit under any patent, patent application, or other +intellectual property right which he or she controls, to the extent +necessary to make, have made, possess, use, and distribute Products. +This immunity does not extend to infringement arising from modifications +subsequently made by others. + +2.2 If you make or have Products made, or distribute Documentation +that you have modified, you grant every Licensor, every other Licensee, +and every possessor or user of Products a perpetual, worldwide, and +royalty-free immunity from suit under any patent, patent application, or +other intellectual property right which you control, to the extent +necessary to make, have made, possess, use, and distribute Products. +This immunity does not extend to infringement arising from modifications +subsequently made by others. + +2.3 To avoid doubt, providing Documentation to a third party for the +sole purpose of having that party make Products on your behalf is not +considered "distribution," and a third party's act of making Products +solely on your behalf does not cause that party to grant the immunity +described in the preceding paragraph. + +2.4 These grants of immunity are a material part of this Agreement, +and form a portion of the consideration given by each party to the +other. If any court judgment or legal agreement prevents you from +granting the immunity required by this Section, your rights under this +Agreement will terminate and you may no longer use, copy, modify or +distribute the Documentation, or make, have made, or distribute +Products. + +3. Modifications +You may modify the Documentation, and those modifications will become +part of the Documentation. They are subject to this Agreement, as are +Products based in whole or in part on them. If you distribute the +modified Documentation, or Products based in whole or in part upon it, +you must email the modified Documentation in a form compliant with +Section 4 to each Licensor who has provided an email address with the +Documentation. Attempting to send the email completes your obligations +under this Section and you need take no further action if any address +fails. + +4. Distributing Documentation +4.1 You may distribute unmodified copies of the Documentation in its +entirety in any medium, provided that you retain all copyright and other +notices (including references to this Agreement) included by each +Licensor, and include an unaltered copy of this Agreement. +4.2 You may distribute modified copies of the Documentation if you +comply with all the requirements of the preceding paragraph and: + (a) include a prominent notice in an ASCII or other open format + file identifying those elements of the Documentation that you + changed, and stating that the modifications are licensed under + the terms of this Agreement; + (b) include all new documentation files that you create, as well as + both the original and modified versions of each file you change + (files may be in your development tool's native file format, + but if reasonably possible, you must also include open format, + such as Gerber, ASCII, Postscript, or PDF, versions); + (c) do not change the terms of this Agreement with respect to + subsequent licensees; and + (d) if you make or have Products made, include in the Documentation + all elements reasonably required to permit others to make + Products, including Gerber, CAD/CAM and other files used for + manufacture. + +5. Making Products +5.1 You may use the Documentation to make or have Products made, +provided that each Product retains any notices included by the Licensor +(including, but not limited to, copyright notices on circuit boards). +5.2 You may distribute Products you make or have made, provided that +you include with each unit a copy of the Documentation in a form +consistent with Section 4. Alternatively, you may include either (i) an +offer valid for at least three years to provide that Documentation, at +no charge other than the reasonable cost of media and postage, to any +person who requests it; or (ii) a URL where that Documentation may be +downloaded, available for at least three years after you last distribute +the Product. + +6. NEW LICENSE VERSIONS +TAPR may publish updated versions of the OHL which retain the same +general provisions as the present version, but differ in detail to +address new problems or concerns, and carry a distinguishing version +number. If the Documentation specifies a version number which applies +to it and "any later version", you may choose either that version or any +later version published by TAPR. If the Documentation does not specify +a version number, you may choose any version ever published by TAPR. +TAPR owns the copyright to the OHL, but grants permission to any person +to copy, distribute, and use it in unmodified form. + +7. WARRANTY AND LIABILITY LIMITATIONS +7.1 THE DOCUMENTATION IS PROVIDED ON AN "AS-IS" BASIS WITHOUT +WARRANTY OF ANY KIND, TO THE EXTENT PERMITTED BY APPLICABLE LAW. ALL +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND +TITLE, ARE HEREBY EXPRESSLY DISCLAIMED. +7.2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL ANY LICENSOR +BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, CONSEQUENTIAL, PUNITIVE, OR EXEMPLARY DAMAGES ARISING OUT OF +THE USE OF, OR INABILITY TO USE, THE DOCUMENTATION OR PRODUCTS, +INCLUDING BUT NOT LIMITED TO CLAIMS OF INTELLECTUAL PROPERTY +INFRINGEMENT OR LOSS OF DATA, EVEN IF THAT PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +7.3 You agree that the foregoing limitations are reasonable due to +the non-financial nature of the transaction represented by this +Agreement, and acknowledge that were it not for these limitations, the +Licensor(s) would not be willing to make the Documentation available to +you. +7.4 You agree to defend, indemnify, and hold each Licensor harmless +from any claim brought by a third party alleging any defect in the +design, manufacture, or operation of any Product which you make, have +made, or distribute pursuant to this Agreement. + #### diff --git a/attic/wispcar/Makefile b/attic/wispcar/Makefile new file mode 100644 index 00000000..8f419eb5 --- /dev/null +++ b/attic/wispcar/Makefile @@ -0,0 +1,25 @@ +# Makefile for Wispcar schematics +# Generates sch PDF +# Derived from the BlackfinOne Makefile - thanks Ivan + +SCH_FILES = wispcarb +PROJECT = wispcarb +REV := $(shell svn info | grep Revision | sed 's/Revision: //') + +SCHPS = $(addsuffix .ps,$(SCH_FILES)) +SCHPDF = $(addsuffix .sch.ps,$(SCH_FILES)) +PWD = $(shell pwd) + +PCB_PRINT_OPTIONS = --ps-color --media A4 + +all: schpdf + +%.ps: %.sch + gschem -o $@ -s gschem-print.scm $^ + +schpdf: $(SCHPS) + -rm *_sch.ps + # sed stuff enlarges gschem font which is too small for my eyes :-) + cat $(SCHPS) | sed 's/scalefont/1.5 mul scalefont/' > $(PROJECT)_sch.ps + ps2pdf $(PROJECT)_sch.ps $(PROJECT)_sch.pdf + diff --git a/attic/wispcar/README b/attic/wispcar/README new file mode 100644 index 00000000..2d8aede4 --- /dev/null +++ b/attic/wispcar/README @@ -0,0 +1,11 @@ +wispcar README +-------------- + +David Rowe 22 June 2009 + +stty is a WRT54GL OpenWRT binary utility some one had compiled on the web, used +for setting serial port speeds + +wispcar.asm is the original code as per the blog post: http://www.rowetel.com/blog/?p=68 + +wispcarb.asm has a mod to the watchdog timer to stay off, used for battery testing diff --git a/attic/wispcar/batt_test.m b/attic/wispcar/batt_test.m new file mode 100644 index 00000000..8e1d008b --- /dev/null +++ b/attic/wispcar/batt_test.m @@ -0,0 +1,34 @@ +% batt_test.m +% David Rowe 23 June 2009 +% Plot battery test results + +function batt_test(f,pngname) + d = load(f); + mins = d(:,1)*60 + d(:,2); + mins = mins - mins(1); + s = sprintf(';%s;',f); + plot(mins, 0.072*d(:,4) + 0.82,s); + xlabel('time (min)'); ylabel('V'); + axis([0 60 11 13]) + grid + + if (nargin == 2) + + % small image + + __gnuplot_set__ terminal png size 420,300 + s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); + eval(s) + replot; + + % larger image + + __gnuplot_set__ terminal png size 800,600 + s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); + eval(s) + replot; + + endif + +endfunction + diff --git a/attic/wispcar/batt_test.sh b/attic/wispcar/batt_test.sh new file mode 100755 index 00000000..e7d472fb --- /dev/null +++ b/attic/wispcar/batt_test.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# batt_test.sh +# David Rowe 22 June 2009 + +if [ $# -ne 2 ] +then + echo "usage ./batt_test.sh cutoff_Vcode logfile" + exit 0 +fi + +/home/stty -F /dev/tts/1 speed 4800 > /dev/null + +rm -f $2 + +# sample initial voltage + +dd if=/dev/tts/1 bs=1 count=36 1>w 2>/dev/null& +echo -n 'w' > /dev/tts/1 +sleep 2 +v=`cut -f 2 -d ' ' w` +echo $v + +# stop when voltage reaches a threshold + +while [ $v -gt $1 ] +do + + # sample voltage + + dd if=/dev/tts/1 bs=1 count=36 1>w 2>/dev/null& + echo -n 'w' > /dev/tts/1 + sleep 2 + v=`cut -f 2 -d ' ' w` + i=`cut -f 3 -d ' ' w` + echo $v $i + + echo -n `date` ' ' >> $2 + echo $v $i >> $2 + + sleep 5 + +done + + diff --git a/attic/wispcar/caliba.m b/attic/wispcar/caliba.m new file mode 100644 index 00000000..3c648b95 --- /dev/null +++ b/attic/wispcar/caliba.m @@ -0,0 +1,29 @@ +% 0.1 ohm current sense resistor 20 June 2009 + +% Vbatt V0.1 I VbattADC IADC +d = [ +[ 8.0 0.121 1.15 36 99] +[ 8.9 0.134 1.27 41 109] +[ 9.8 0.148 1.40 44 121] +[ 11.1 0.167 1.58 50 136] +[ 12.7 0.191 1.80 58 153] +[ 13.1 0.198 1.87 59 159] +] + +figure(1) +plot(d(:,1), d(:,4)) +ylabel("ADC V"); xlabel("Vbatt (V)"); + +figure(2) +plot(d(:,3), d(:,5)) +ylabel('ADC I'); xlabel('I (A)'); + +figure(3) +plot(d(:,2), d(:,3)) +xlabel('Vsense I'); ylabel('I (A)'); + +figure(4) +plot(d(:,2), d(:,5)) +xlabel('Vsense I'); ylabel('ADC I'); +grid + diff --git a/attic/wispcar/calibb.m b/attic/wispcar/calibb.m new file mode 100644 index 00000000..3600688b --- /dev/null +++ b/attic/wispcar/calibb.m @@ -0,0 +1,29 @@ +% 0.1 ohm current sense resistor 20 June 2009 + +% Vbatt VbattADC IADC +d = [ +[ 9.2 118 ] +[ 10.0 129 ] +[ 11.1 142 ] +[ 12.2 156 ] +[ 13.2 169 ] +[ 14.0 179 ] +] + +d1 = [ +[ 12.12 157 ] +[ 12.00 155 ] +[ 11.86 153 ] +[ 11.68 151 ] +[ 11.47 148 ] +] + +figure(1) +plot(d(:,1), d(:,2)) +hold on +plot(d1(:,1), d1(:,2),'g') +hold off +ylabel("ADC V"); xlabel("Vbatt (V)"); +grid +axis([11 13 140 170]) + diff --git a/attic/wispcar/countdown.c b/attic/wispcar/countdown.c new file mode 100644 index 00000000..a35575bf --- /dev/null +++ b/attic/wispcar/countdown.c @@ -0,0 +1,37 @@ +/* used to prototype algorithm for 3 digit count down timer used in wispcar.asm */ + +#include +#include + +int main() { + int x,y,z; + + x = 1; + y = 2; + z = 3; + + while(1) { + if (z == 0) { + if (y == 0) { + if (x == 0) { + exit(0); + } + else { + x--; + y = 9; + z = 9; + } + } + else { + y--; + z = 9; + } + } + else { + z--; + } + printf("%d%d%d\n",x,y,z); + } + +} + diff --git a/attic/wispcar/documentation.txt b/attic/wispcar/documentation.txt new file mode 100644 index 00000000..26e7de39 --- /dev/null +++ b/attic/wispcar/documentation.txt @@ -0,0 +1,240 @@ +documentation.txt +Created by David Rowe May 2008 +Wispcar project + +Files +----- + +wispcar.asm........: PIC source code, compile and simulate + with Windows MPLAB 8.10 (free download) + Also explains Wispcar commands +wispcar.sch........: gEDA gschem schematic +Makefile...........: Creates PDF of schematic +documentation.txt..: This file + +Project Plan +------------ + +[ ] WP100 Documentation + [ ] Create SVN repository + [ ] Draw schematic + [ ] Write Test Report + + Discuss tests performed + + how to repeat them + + results + [ ] Software + [ ] Write Design Notes + + explain various sections of design + + discuss trade offs + +[ ] WP200 Prototype Development + [ ] Breadboard Prototype + [X] PIC with RS232 + [X] Current sensor + + high-side op-amp differential amp + [X] Power Switch + + used to switch power to AP + + controlled by watchdog and sleep function + [ ] Linear Regulator + [X] Watchdog software + [X] Sleep software + [ ] Construct Soldered Prototype + [ ] Install in Solar powered AP (Rowetel) + +[ ] WP300 Testing + [ ] Test 1: false watchdog firing + + test_watchdog.tcl Exepct script + + sends 'w' every sec, look for false WD fire + + results: after approx 40 hrs, 91,000 seconds, no false firing + + [ ] Test to determine watchdog doesn't fire by mistake + + leave running for 1 week + + stable power & router + + ensure watchdog doesn't fire by mistake + [ ] Dirty power test + + work out a way to simulate a poor power supply + + for example put power supply in series with transformer + secondary, then modulate primary with pulses + + this will give big spikes on power line + + make sure PIC never hangs + [ ] Brown out test + + vary Vbat from 30V down to 2V 10 times + + make sure PIC does not hang + +Specs: +----- + +1/ Measures Vbat and Ibat. + + Vbat between 5 and 60V + Ibat between 0 and 5A + + Measures Vbat and Ibat and reports every 1 sec to Host. + +2/ Watchdog + + Fires if no RS232 rx for TBD1 secs from host + Power is shut off for 5 seconds then reapplied + +3/ Sleep + + Send "sleepXXXX" to put power supply to sleep for XXXX seconds + +4/ Current consumption (estimated) + + Vbat = 30V I=2mA + Vbat = 5V I=2mA + + Note: we need to work out a way to get 60V operation, 78L05 + regulator can't go above 35V. + +References +---------- + +1/ Zener power supply design: + + http://www.kpsec.freeuk.com/powersup.htm + +2/ PIC10F510 datasheet from Microchip + +3/ 78L05 datasheet + +4/ IRF9540 datasheet + +Credits +------- + +Tim Ansell (Mithro) for lending me his PIC collection and programmer +Yahel Ben-David + +Notes +----- + +1/ IRF9640 FET was selected largely at random. At 19A max it may be +overkill, a cheaper FET may be more suitable. + +2/ The RS232 polarity may need to change when directly connected to a +router without level conversion, see reference docs for RS232 software +UART code in wispcar.asm. I used a MAX232 type chip for interfacing +the RS232 tx & rx to a PC's serial port for testing. + +Gotchas +------- + +1/ On the PIC12F510 we can only use 'call' to call an address in the +first 256 bytes, so put all funcs at the start of the program, main at +the end. + +2/ If the RS232 characters have occasional errors, the internal clock +oscillator may need tweaking. You can check the baud rate of the +RS232 signals using an oscilloscope, at 4800 baud the bit period +should be 208us. See PIC data sheet for information on adjusting the +internal oscillator. + +3/ The Vce(max) rating of Q2 is 35V, and Vgs(max) of Q1 +/- 20V. As +R1/R2 form a voltage divider I think this sets the maximum Vbat at 35V +for the current version, i.e. Q1 will pop first (as Vgs will hit 20V +when Vbat=40V). Need higher Vce Q2 or change circuit to limit +Vgs(max). Need to make sure sufficient Vgs to switch on Q1 at low +Vbat. Maybe two versions with different R1/R2? + +4/ Current Sensor resistor values. When building the first soldered +prototype I found that residual flux messed up the 10M R11 feedback +resistor. Scraping flux away and cleaning with solvent brought the +resistance back up again. This could be a problem with home +construction, and possibly humid environments. Perhaps we should +scale resistors down to say 100k/10k voltage dividers, 1M R11? + +5/ When building the first soldered prototype I found that the +position of the ground wires carrying high current caused the current +sensor to stop working (stuck at 0V). U2 GND and the GND of R7, R9, +R10 where at different places along the GND track carrying 0.5A. This +caused a voltage drop of about 5mV between the two GNDs. I moved the +ground connection (made the GND in GND out points close to each other +so 0.5A was only flowing thru a short section of track) and the +current sensor started working again. This suggests a carefully laid +out PCB is a good idea. + +6/ The voltage on pins 2 & 3 of U2 (+/i op-amp input) should be within +10 mV of each other with U2 unplugged. A greater difference indicates +one of the resistor values is wrong. + +TODO List +--------- + +[ ] schematic + [X] pinout of 78L05 + [X] pinout of power FET + [X] pinout of BC548 + [ ] connect + & - together on unsued op-amp sections + [X] TAPR open harwdare license +[ ] PCB ideas + [ ] extra pads for zener to drop input voltage + [ ] extra pads for general prototyping + [ ] break out extra op amp pins + + dont hard-tie them + +[X] svn repository + + with datasheet pdfs ? +[ ] wire correctly for power on reset + + test with dodgy power on curve (slow power up) +[ ] unused LM324 inputs + + check if its really OK to GND them +[X] blog post +[ ] test at 5A for 24 Hrs + + given FET on-resistance do we need a heat sink? +[X] README in SVN + + this file +[ ] Add 4th digit to sleep timer +[ ] test with WRT54 +[ ] add brown out detector to PIC reset to be double sure? + + see PIC data sheet +[ ] check what happens in overvoltage on input, how can we protect? +[ ] document test plan +[ ] get PIC part name right in symbol file +[ ] meausure the current consumption of the soldered prototype +[ ] Indicate single point grounding on schematic +[ ] Note 1% R's on schematic +[X] make sure we can't stall in RS232 input routine + + need a way to get around this..... + + malformed RS323 could cause a hang + + maybe better to just look at h/l transition or something? + + sep pic for sleep function? + + solution: integrate 1 sec delay with RS232 rx +[ ] Limitations + + need to send full command before 1 second delay? + + like send command immediately after ADC data + + need automatic reset from fragment + + like once every second + + or can it be spread over cycles? +[ ] enable PIC watchdog timer + + how can we test? +[ ] How repeatable is current sensor? + + y intercept (DC offset) + + slope + + maybe build a few a check +[ ] make sure all RS232 chars OK + + how to prog with calibrated clock? + + check baud rate + + is max232 OK at Vcc=5V? +[ ] programming procedure to preserve osccal +[X] make function to print decimal, rather than repeating all that code + + we can't as call stack is only two levels deep and we are at the limit + +[ ] automatic thrash tests (repeat each one for hours/days) + + maybe use expect + [ ] send sleep + + make sure we sleep + [ ] send 'w' + + make sure we dont WD time out + [ ] check for unlikely WD/sleep/reboot events + + especially under nasty conditions + +[ ] check how accurate the timing is + + is 1 sec delay accurate? + +[ ] work out how to run from 60V + + 78L05 pops at 35V + +[ ] Will 5V levels from PIC play nicely with 3V3 levels of router - +check data sheets! diff --git a/attic/wispcar/gafrc b/attic/wispcar/gafrc new file mode 100644 index 00000000..601dd2e3 --- /dev/null +++ b/attic/wispcar/gafrc @@ -0,0 +1,3 @@ +(component-library "sym") +(source-library "sym") + diff --git a/attic/wispcar/gschem-print.scm b/attic/wispcar/gschem-print.scm new file mode 100644 index 00000000..57739299 --- /dev/null +++ b/attic/wispcar/gschem-print.scm @@ -0,0 +1,14 @@ +(paper-size 11.5 8.5) +(load (string-append gedadatarc "/gschem-lightbg")) ; light background +(output-type "limits") +(output-color "enabled") + +(text-color 9 "green4" "green4" "0 0 0" 0 0 0) ; light background +(net-endpoint-color 2 "red" "red3" ".502 .094 .062" 128 24 16) ; light +(graphic-color 3 "green4" "green4" "0 0 0" 0 0 0) ; light background +(net-color 4 "blue2" "blue3" "0 0 0" 0 0 0) ; light background + +(output-text "ps") +(gschem-use-rc-values) ;You need call this after you call any +(gschem-print "dummyfilename") ;filename is specified on the command line +(gschem-exit) diff --git a/attic/wispcar/log2octave.sh b/attic/wispcar/log2octave.sh new file mode 100755 index 00000000..7067eb85 --- /dev/null +++ b/attic/wispcar/log2octave.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# log2octave.sh +# David Rowe 23 June 2009 + +# strip out time stamp and voltage into four columns so octave batt_test.m +# can read + +cut -f 4,8 -d ' ' $1 | sed -e 's/:/ /g' > $1.oct diff --git a/attic/wispcar/stty b/attic/wispcar/stty new file mode 100755 index 00000000..d350fcde Binary files /dev/null and b/attic/wispcar/stty differ diff --git a/attic/wispcar/sym/LM78L05.sym b/attic/wispcar/sym/LM78L05.sym new file mode 100644 index 00000000..c441fd52 --- /dev/null +++ b/attic/wispcar/sym/LM78L05.sym @@ -0,0 +1,39 @@ +v 20060906 1 +T 400 600 9 8 1 0 0 0 1 +IN +T 948 600 9 8 1 0 0 0 1 +OUT +T 900 100 9 8 1 0 0 0 1 +78L05 +B 300 300 1000 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +T 1600 1300 5 10 0 0 0 0 1 +device=78L05 +T 656 401 9 8 1 0 0 0 1 +GND +P 300 600 0 600 1 0 1 +{ +T 100 650 5 8 1 1 0 0 1 +pinnumber=1 +T 100 650 5 8 0 0 0 0 1 +pinseq=1 +} +P 800 0 800 300 1 0 0 +{ +T 700 100 5 8 1 1 0 0 1 +pinnumber=2 +T 700 100 5 8 0 0 0 0 1 +pinseq=2 +} +P 1300 600 1600 600 1 0 1 +{ +T 1430 650 5 8 1 1 0 0 1 +pinnumber=3 +T 1430 650 5 8 0 0 0 0 1 +pinseq=3 +} +T 1400 1000 8 10 1 1 0 6 1 +refdes=U? +T 1600 1100 5 10 0 0 0 0 1 +pins=3 +T 1600 900 5 10 0 0 0 0 1 +net=GND:2 diff --git a/attic/wispcar/sym/PC12F510.sym b/attic/wispcar/sym/PC12F510.sym new file mode 100644 index 00000000..7198d934 --- /dev/null +++ b/attic/wispcar/sym/PC12F510.sym @@ -0,0 +1,86 @@ +v 20060906 1 +B 300 200 1200 1600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +P 0 1600 300 1600 1 0 0 +{ +T 200 1650 5 8 1 1 0 6 1 +pinnumber=1 +T 400 1550 5 8 1 1 0 0 1 +pinlabel=VCC +T 0 1950 5 8 0 1 0 2 1 +pintype=pwr +} +P 0 400 300 400 1 0 0 +{ +T 200 450 5 8 1 1 0 6 1 +pinnumber=4 +T 400 350 5 8 1 1 0 0 1 +pinlabel=GP3 +T 0 750 5 8 0 1 0 2 1 +pintype=in +} +P 0 800 300 800 1 0 0 +{ +T 200 850 5 8 1 1 0 6 1 +pinnumber=3 +T 400 750 5 8 1 1 0 0 1 +pinlabel=GP4 +T 0 1050 5 8 0 1 0 2 1 +pintype=tri +} +P 0 1200 300 1200 1 0 0 +{ +T 200 1250 5 8 1 1 0 6 1 +pinnumber=2 +T 400 1150 5 8 1 1 0 0 1 +pinlabel=GP5 +T 0 1550 5 8 0 1 0 2 1 +pintype=tri +} +T 2400 800 5 10 0 0 0 0 1 +device=PIC12F510 +T 1650 150 9 10 1 1 180 0 1 +PIC12F510 DIP8 +T 2400 500 5 10 0 0 0 0 1 +footprint=DIP8 +T 2400 200 5 10 0 0 0 0 1 +description=PCI Microcontroller +T -1300 500 5 10 0 0 0 0 1 +numslots=0 +P 1800 1600 1500 1600 1 0 0 +{ +T 1600 1650 5 8 1 1 0 0 1 +pinnumber=8 +T 1450 1550 5 8 1 1 0 6 1 +pinlabel=GND +T 2100 1700 5 8 0 1 0 8 1 +pintype=pwr +} +P 1800 400 1500 400 1 0 0 +{ +T 1600 450 5 8 1 1 0 0 1 +pinnumber=5 +T 1450 350 5 8 1 1 0 6 1 +pinlabel=GP2 +T 2000 450 5 8 0 1 0 8 1 +pintype=io +} +P 1800 800 1500 800 1 0 0 +{ +T 1600 850 5 8 1 1 0 0 1 +pinnumber=6 +T 1450 750 5 8 1 1 0 6 1 +pinlabel=GP1 +T 2000 950 5 8 0 1 0 8 1 +pintype=io +} +P 1800 1200 1500 1200 1 0 0 +{ +T 1600 1250 5 8 1 1 0 0 1 +pinnumber=7 +T 1450 1150 5 8 1 1 0 6 1 +pinlabel=GP0 +T 2050 1300 5 8 0 1 0 8 1 +pintype=tri +} +T 550 1950 8 10 1 1 0 6 1 +refdes=U? diff --git a/attic/wispcar/sym/bf-5V-plus-1.sym b/attic/wispcar/sym/bf-5V-plus-1.sym new file mode 100644 index 00000000..17c7f7fb --- /dev/null +++ b/attic/wispcar/sym/bf-5V-plus-1.sym @@ -0,0 +1,15 @@ +v 20060123 1 +P 200 0 200 200 1 0 0 +{ +T 250 50 5 6 0 1 0 0 1 +pinnumber=1 +T 250 50 5 6 0 0 0 0 1 +pinseq=1 +T 900 100 5 10 0 0 0 0 1 +pintype=pas +} +L 50 200 350 200 3 0 0 0 -1 -1 +T 75 250 9 8 1 0 0 0 1 ++5V +T 300 0 8 8 0 0 0 0 1 +net=+5V:1 diff --git a/attic/wispcar/sym/bf-capacitor-1.sym b/attic/wispcar/sym/bf-capacitor-1.sym new file mode 100644 index 00000000..d5c40eca --- /dev/null +++ b/attic/wispcar/sym/bf-capacitor-1.sym @@ -0,0 +1,31 @@ +v 20050820 1 +P 0 200 200 200 1 0 0 +{ +T 100 250 5 8 0 1 0 0 1 +pinnumber=1 +T 100 250 5 8 0 0 0 0 1 +pinseq=1 +T 0 100 5 10 0 0 0 0 1 +pintype=pas +} +P 900 200 700 200 1 0 0 +{ +T 700 250 5 8 0 1 0 0 1 +pinnumber=2 +T 700 250 5 8 0 0 0 0 1 +pinseq=2 +T 0 100 5 10 0 0 0 0 1 +pintype=pas +} +L 400 400 400 0 3 0 0 0 -1 -1 +L 500 400 500 0 3 0 0 0 -1 -1 +L 700 200 500 200 3 0 0 0 -1 -1 +L 400 200 200 200 3 0 0 0 -1 -1 +T 300 600 5 10 0 0 0 0 1 +device=CAPACITOR +T 200 500 8 10 1 1 0 0 1 +refdes=C? +T 0 0 8 10 0 1 0 0 1 +pins=2 +T 0 0 8 10 0 1 0 0 1 +class=DISCRETE diff --git a/attic/wispcar/sym/bf-capacitor-2.sym b/attic/wispcar/sym/bf-capacitor-2.sym new file mode 100644 index 00000000..162c82b1 --- /dev/null +++ b/attic/wispcar/sym/bf-capacitor-2.sym @@ -0,0 +1,33 @@ +v 20031231 1 +P 0 200 200 200 1 0 0 +{ +T 100 250 5 8 0 1 0 0 1 +pinnumber=1 +T 100 250 5 8 0 0 0 0 1 +pinseq=1 +T 0 100 5 10 0 0 0 0 1 +pintype=pas +} +P 900 200 700 200 1 0 0 +{ +T 700 250 5 8 0 1 0 0 1 +pinnumber=2 +T 700 250 5 8 0 0 0 0 1 +pinseq=2 +T 0 100 5 10 0 0 0 0 1 +pintype=pas +} +L 400 400 400 0 3 0 0 0 -1 -1 +L 700 200 500 200 3 0 0 0 -1 -1 +L 400 200 200 200 3 0 0 0 -1 -1 +T 400 600 5 10 0 0 0 0 1 +device=POLARIZED_CAPACITOR +A 1200 200 700 165 30 3 0 0 0 -1 -1 +L 289 400 289 300 3 0 0 0 -1 -1 +L 340 349 240 349 3 0 0 0 -1 -1 +T 200 500 8 10 1 1 0 0 1 +refdes=C? +T 0 0 8 10 0 1 0 0 1 +pins=2 +T 0 0 8 10 0 1 0 0 1 +class=DISCRETE diff --git a/attic/wispcar/sym/bf-osc-1.sym b/attic/wispcar/sym/bf-osc-1.sym new file mode 100644 index 00000000..904040af --- /dev/null +++ b/attic/wispcar/sym/bf-osc-1.sym @@ -0,0 +1,60 @@ +v 20050820 1 +B 300 200 1200 700 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +P 1800 400 1500 400 1 0 0 +{ +T 1600 450 5 8 1 1 0 0 1 +pinnumber=1 +T 1600 450 5 8 0 1 0 0 1 +pinseq=1 +T 1400 350 5 8 1 1 0 6 1 +pinlabel=EN +T 1600 450 5 8 0 1 0 8 1 +pintype=pas +} +P 0 700 300 700 1 0 0 +{ +T 200 750 5 8 1 1 0 6 1 +pinnumber=4 +T 200 750 5 8 0 1 0 6 1 +pinseq=4 +T 400 650 5 8 1 1 0 0 1 +pinlabel=VCC +T 200 750 5 8 0 1 0 2 1 +pintype=pwr +} +P 1800 700 1500 700 1 0 0 +{ +T 1600 750 5 8 1 1 0 0 1 +pinnumber=3 +T 1600 750 5 8 0 1 0 0 1 +pinseq=2 +T 1400 650 5 8 1 1 0 6 1 +pinlabel=OUT +T 1600 750 5 8 0 1 0 8 1 +pintype=out +} +P 0 400 300 400 1 0 0 +{ +T 200 450 5 8 1 1 0 6 1 +pinnumber=2 +T 200 450 5 8 0 1 0 6 1 +pinseq=3 +T 400 350 5 8 1 1 0 0 1 +pinlabel=GND +T 200 450 5 8 0 1 0 2 1 +pintype=pwr +} +T 1900 800 5 10 0 0 0 0 1 +device=CLOCK OSC +T 1450 150 9 10 1 1 180 0 1 +CLOCK OSC +T 1900 500 5 10 0 0 0 0 1 +footprint=bf_XTALOSC +T 1900 200 5 10 0 0 0 0 1 +description=Hi-Q QMSO-4200 Series +T 1900 0 5 10 0 0 0 0 1 +documentation=TBD +T 300 1100 8 10 1 1 0 0 1 +refdes=U? +T -1300 500 5 10 0 0 0 0 1 +numslots=0 diff --git a/attic/wispcar/sym/bf-resistor-1.sym b/attic/wispcar/sym/bf-resistor-1.sym new file mode 100644 index 00000000..b2ea8c72 --- /dev/null +++ b/attic/wispcar/sym/bf-resistor-1.sym @@ -0,0 +1,34 @@ +v 20050820 1 +L 600 200 500 0 3 0 0 0 -1 -1 +L 500 0 400 200 3 0 0 0 -1 -1 +L 400 200 300 0 3 0 0 0 -1 -1 +L 300 0 200 200 3 0 0 0 -1 -1 +T 300 400 5 10 0 0 0 0 1 +device=RESISTOR +L 600 200 700 0 3 0 0 0 -1 -1 +L 700 0 750 100 3 0 0 0 -1 -1 +P 900 100 750 100 1 0 0 +{ +T 800 150 5 8 0 1 0 0 1 +pinnumber=2 +T 800 150 5 8 0 0 0 0 1 +pinseq=2 +T 900 100 5 10 0 0 0 0 1 +pintype=pas +} +P 0 100 152 100 1 0 0 +{ +T 100 150 5 8 0 1 0 0 1 +pinnumber=1 +T 100 150 5 8 0 0 0 0 1 +pinseq=1 +T 0 100 5 10 0 0 0 0 1 +pintype=pas +} +L 201 200 150 100 3 0 0 0 -1 -1 +T 200 300 8 10 1 1 0 0 1 +refdes=R? +T 0 0 8 10 0 1 0 0 1 +pins=2 +T 0 0 8 10 0 1 0 0 1 +class=DISCRETE diff --git a/attic/wispcar/sym/d7400.sym b/attic/wispcar/sym/d7400.sym new file mode 100644 index 00000000..0e1976c5 --- /dev/null +++ b/attic/wispcar/sym/d7400.sym @@ -0,0 +1,69 @@ +v 20060123 1 +L 300 100 300 700 3 0 0 0 -1 -1 +L 300 700 700 700 3 0 0 0 -1 -1 +T 500 800 5 10 0 0 0 0 1 +device=7400 +T 500 1000 5 10 0 0 0 0 1 +slot=1 +T 500 1200 5 10 0 0 0 0 1 +numslots=4 +T 500 1400 5 10 0 0 0 0 1 +slotdef=1:1,2,3 +T 500 1600 5 10 0 0 0 0 1 +slotdef=2:4,5,6 +T 500 1800 5 10 0 0 0 0 1 +slotdef=3:9,10,8 +T 500 2000 5 10 0 0 0 0 1 +slotdef=4:12,13,11 +L 300 100 700 100 3 0 0 0 -1 -1 +A 700 400 300 270 180 3 0 0 0 -1 -1 +V 1050 400 50 6 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +P 1100 400 1300 400 1 0 1 +{ +T 1100 450 5 8 1 1 0 0 1 +pinnumber=3 +T 1100 350 5 8 0 1 0 2 1 +pinseq=3 +T 950 400 9 8 0 1 0 6 1 +pinlabel=Y +T 950 400 5 8 0 1 0 8 1 +pintype=out +} +P 300 200 0 200 1 0 1 +{ +T 200 250 5 8 1 1 0 6 1 +pinnumber=2 +T 200 150 5 8 0 1 0 8 1 +pinseq=2 +T 350 200 9 8 0 1 0 0 1 +pinlabel=B +T 350 200 5 8 0 1 0 2 1 +pintype=in +} +P 300 600 0 600 1 0 1 +{ +T 200 650 5 8 1 1 0 6 1 +pinnumber=1 +T 200 550 5 8 0 1 0 8 1 +pinseq=1 +T 350 600 9 8 0 1 0 0 1 +pinlabel=A +T 350 600 5 8 0 1 0 2 1 +pintype=in +} +T 300 800 8 10 1 1 0 0 1 +refdes=U? +T 500 2150 5 10 0 0 0 0 1 +footprint=DTSSOP-14 +T 500 2350 5 10 0 0 0 0 1 +description=4 NAND gates with 2 inputs +T 500 2550 5 10 0 0 0 0 1 +documentation=http://www-s.ti.com/sc/ds/sn74hc00.pdf +T 0 0 8 8 0 0 0 0 1 +author=Ivan Danov +T 0 0 8 8 0 0 0 0 1 +email=idanov@gmail.com +T 0 0 8 8 0 0 0 0 1 +dist-license=GPL +T 0 0 8 8 0 0 0 0 1 +use-license=unlimited diff --git a/attic/wispcar/sym/pmos-wispcar.sym b/attic/wispcar/sym/pmos-wispcar.sym new file mode 100644 index 00000000..941dda5d --- /dev/null +++ b/attic/wispcar/sym/pmos-wispcar.sym @@ -0,0 +1,52 @@ +v 20060906 1 +T 600 500 5 10 0 0 0 0 1 +device=PMOS_TRANSISTOR +T 600 500 5 10 0 0 0 0 1 +numslots=0 +T 600 500 5 10 0 0 0 0 1 +description=generic P channel MOS transistor (enhancement type) +L 250 600 500 600 3 0 0 0 -1 -1 +L 250 200 500 200 3 0 0 0 -1 -1 +L 300 350 400 400 3 0 0 0 -1 -1 +L 300 450 400 400 3 0 0 0 -1 -1 +P 0 200 200 200 1 0 0 +{ +T 0 300 5 10 0 1 0 0 1 +pinnumber=G +T 0 300 9 10 1 1 0 0 1 +pinlabel=G +T 0 300 5 10 0 0 0 0 1 +pinseq=2 +T 0 300 5 10 0 0 0 0 1 +pintype=pas +} +P 500 600 500 800 1 0 1 +{ +T 300 700 5 10 0 1 0 0 1 +pinnumber=D +T 300 700 9 10 1 1 0 0 1 +pinlabel=D +T 300 700 5 10 0 0 0 0 1 +pinseq=1 +T 300 700 5 10 0 0 0 0 1 +pintype=pas +} +P 500 200 500 0 1 0 1 +{ +T 300 0 5 10 0 1 0 0 1 +pinnumber=S +T 300 0 9 10 1 1 0 0 1 +pinlabel=S +T 300 0 5 10 0 0 0 0 1 +pinseq=3 +T 300 0 5 10 0 0 0 0 1 +pintype=pas +} +T 700 600 8 10 1 1 0 0 1 +refdes=Q? +L 250 675 250 525 3 0 0 0 -1 -1 +L 250 475 250 325 3 0 0 0 -1 -1 +L 250 275 250 125 3 0 0 0 -1 -1 +L 200 600 200 200 3 0 0 0 -1 -1 +L 250 400 400 400 3 0 0 0 -1 -1 +L 400 400 400 200 3 0 0 0 -1 -1 diff --git a/attic/wispcar/test_watchdog.tcl b/attic/wispcar/test_watchdog.tcl new file mode 100755 index 00000000..41e84117 --- /dev/null +++ b/attic/wispcar/test_watchdog.tcl @@ -0,0 +1,38 @@ +#!/usr/local/bin/expect -f +# test_watchdog.tcl - Expect script to test wispcar watch dog timer. +# +# Assumes /etc//etc/minirc.mini4800.dfl config file configured for +# 4800 baud + +set rs232 dragonballz +set send_slow {1 0.2} +set timeout -1 + +# connect to machine with RS232 port + +spawn ssh $rs232 +expect "$ " +send "killall -9 minicom\r" +expect "$ " +send "minicom mini4800.dfl\r" + +# Keep sending 'w' every second +# This shoud mean WD _never_ times out + +set fire 0 +set count 0 +while {1} { + send "w" + expect -re "(...) (...) (.) (...) (...) (...) (.) (...) (.)" + set v $expect_out(1,string) + set w $expect_out(9,string) + if {$w == "w"} { + # watchdog has fired + set fire [expr $fire+1] + send "w" + } + set count [expr $count+1] + puts "count: $count fire: $fire" +} + +close diff --git a/attic/wispcar/wispcar.asm b/attic/wispcar/wispcar.asm new file mode 100644 index 00000000..a6a3bb10 --- /dev/null +++ b/attic/wispcar/wispcar.asm @@ -0,0 +1,1008 @@ +; wispcar.asm +; David Rowe May 2008 +; +; PIC12F510 Assembler program, MPLAB V8.10 IDE used to build. +; +; ******************************************************** +; * Wifi Station Power Controller And Reporter - WiSPCaR * +; ******************************************************** +; +;--------------------------------------------------------------------- +; Copyright (C) 2008 David Rowe +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; 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. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +; USA +;--------------------------------------------------------------------- +; +; FUNCTIONS +; ========= +; +; 1/ Monitor Voltage +; 2/ Monitor Current +; 3/ Watchdog timer +; 4/ Sleep timer +; +; +; PINOUT +; ====== +; ____ ____ +; | \/ | +; Vcc --| 1 8 |-- GND +; | | +; Spare I/O --| 2 7 |-- Vsense (in) +; | | +; RS232 Tx (out) --| 3 6 |-- PowerSwitch (out) +; | | +; RS232 Rx (in) --| 4 5 |-- Isense (in) +; |__________| +; +; +; Pin | Function | PIC Name +; -----|-------------|--------- +; 2 | Spare I/O | GP5 +; 3 | RS232 Tx | GP4 +; 4 | RS232 Rx | GP3 +; 5 | Isense | AN2 +; 6 | PowerSwitch | GP1 +; 7 | Vsense | AN0 +; +; +; PIC PROGRAMMING OPTIONS +; ======================= +; +; 8MHz clock, MCLRE=I/O, INTOSC +; +; +; 4800 BAUD RS232 OUTPUT +; ====================== +; +; The following line is printed every time you send 'w' or '.', if you +; send nothing to wispcar it will remain silent. The specific chars +; minimise the chance of wispcar interfering with your boot loader. +; +; Name of script on host that parses this line +; | Vsense +; | | Isense +; | | | char received (ASCII) +; | | | | Last char received (decimal) +; | | | | | Watchdog timeout counter +; | | | | | | Watchdog fire counter +; | | | | | | | Sleep state machine state +; | | | | | | | | Sleep timeout counter +; | | | | | | | | | +; wispcar 040 031 - 032 012 000 0 000 w---reason for last restart +; b - Wispcar (re)booted +; w - watchdog timer fired +; s - we went to sleep +; - - restart flag reset +; +; COMMANDS +; ======== +; +; 1/ Send a 'w' every WD_TIMEOUT seconds to prevent Watchdog timer +; firing and cutting power. +; +; 2/ Send a '.' to report status without resetting watchdog. +; +; 3/ Send the string 'sleepxyz' to cut the power for xyz seconds, +; where x,y and z are digits in the range 0-9. If any part of the +; string is invalid it will be ignored. Wait 5 seconds and start +; again. +; +; 4/ Wispcar cannot rx and tx RS232 at the same time. Wait until after +; the current output has finished to send the next command. It is best to +; wait until just after the output line is received by the host, then +; send your command. If the command (such as sleep) gets messed up, +; just wait 5 seconds and wispcar will reset it's internal state +; machine. You can then try again. +; +; 4/ The final field is reset to a space when a 'w' is sent to +; Wispcar. This field lets the host know just _why_ it was rebooted. + + +#include + +; VARIABLES --------------------------------------------------------------------- + +TEMP equ 0x10 +SERBUF equ 0x11 ; RS232 char to transmit +count equ 0x12 ; temp reg used by "BIN2BCD" and "baud" routines +BIN equ 0x13 +huns equ 0x14 +tens equ 0x15 +ones equ 0x16 +thirty equ 0x17 ; constant set to (guess what) 30 +SERBUFI equ 0x18 ; last RS232 character we received +wd_timeout equ 0x19 ; current watchdog timer value (in secs) + ; when this hits zero we turn the power off +wd_fire equ 0x1a ; count down timer when watchdog fires (in secs) +restart_flag equ 0x1b ; tells host why we just restarted (WD or sleep) + +sleep_state equ 0x1c +sleep_timeout equ 0x1d ; current value of sleep time out (in secs) + ; measures time between rx-ed chars in + ; s-l-e-e-p-x-y-z sequence. + ; If this hits zero (like s-l- (BIG GAP)) + ; we assume sleep command + ; was invalid and we reset the input state machine + + ; three digit sleep time (up to 999 secs) + ; these count down to zero while we are sleeping + ; when count down hits 0 power is switched back on + +sleeping equ 0x1e ; asserted if we are sleeping (power off) + +; following variables are in bank1, which makes life difficult.... + +d1 equ 0x10 +d2 equ 0x11 +d3 equ 0x12 + +x equ 0x13 ; sleep time (hundreds of secs) +y equ 0x14 ; sleep time (tens of secs) +z equ 0x15 ; sleep time (secs) + +; CONSTANTS --------------------------------------------------------------------- + +WD_TIMEOUT equ d'18' ; watchdog timeout in seconds +WD_FIRE equ d'5' ; watchdog firing time in seconds + ; how long power is cut off to host + +SLEEP_TIMEOUT equ d'5' ; timeout between rx-ed chars in sleep input + ; sequence. + +; Values for restart_flag - tell host why we just cut power after we woke up + +BOOT_FLAG equ 'b' ; Wispcar just rebooted +WD_FLAG equ 'w' ; Watchdog fired +SLEEP_FLAG equ 's' ; We slept + +; START PROGRAM ---------------------------------------------------------------- + +; set up osc cal (temp code just for experimenting) +; TODO - FIX ME for general case + + movlw 16 + movwf OSCCAL + +; configure AN[1:0] as analog inputs + + movlw b'10110001' + movwf ADCON0 + +; configure GP[3] as digital input (RS232 RX) +; configure GP[4] as digital output (RS232 TX) +; configure GP[1] as digital output (PowerSwitch) + +; disble the comparitor so we can use GP[1] + + bcf CM1CON0,3 + + ; set up GPIO directions + + movlw b'00001101' + tris GPIO + +; turn on PowerSwitch + + bsf GPIO,1 + +; set up a convenient constant + + movlw h'30' + movwf thirty + +; init watchdog + + movlw WD_TIMEOUT + movwf wd_timeout + clrf wd_fire + +; init sleep + + clrf sleep_state + clrf sleeping + clrf sleep_timeout + bsf FSR,5 ; x,y,z are in bank 1 (grumble) + clrf x + clrf y + clrf z + bcf FSR,5 ; x,y,z are in bank 1 (grumble) + +; init restart_flag + + movlw BOOT_FLAG + movwf restart_flag + + goto main + +; START FUNCTIONS ------------------------------------------------------------ + +; BIN2BCD +; +; Convert 8 bit value in BIN to a 3 digit decimal value. +; +; in.......: BIN +; out......: huns, tens, ones +; Reference: http://www.piclist.com/techref/microchip/math/radix/b2a-8b3d-ab.htm +; +; Uses temp reg 'count' + +; uses ADD-3 algorithm + +BIN2BCD + movlw 8 + movwf count + clrf huns + clrf tens + clrf ones +BCDADD3 + movlw 5 + subwf huns, 0 + btfsc STATUS, C + CALL ADD3HUNS + + movlw 5 + subwf tens, 0 + btfsc STATUS, C + CALL ADD3TENS + + movlw 5 + subwf ones, 0 + btfsc STATUS, C + CALL ADD3ONES + + decf count, 1 + bcf STATUS, C + rlf BIN, 1 + rlf ones, 1 + btfsc ones,4 ; + CALL CARRYONES + rlf tens, 1 + + btfsc tens,4 ; + CALL CARRYTENS + rlf huns,1 + bcf STATUS, C + + movf count, 0 + btfss STATUS, Z + GOTO BCDADD3 + + movf huns, 0 ; add ASCII Offset + addwf thirty, 0 + movwf huns + + movf tens, 0 ; add ASCII Offset + addwf thirty, 0 + movwf tens + + movf ones, 0 ; add ASCII Offset + addwf thirty, 0 + movwf ones + + retlw 0 + +ADD3HUNS + movlw 3 + addwf huns,1 + retlw 0 + +ADD3TENS + movlw 3 + addwf tens,1 + retlw 0 + +ADD3ONES + movlw 3 + addwf ones,1 + retlw 0 + +CARRYONES + bcf ones, 4 + bsf STATUS, C + retlw 0 + +CARRYTENS + bcf tens, 4 + bsf STATUS, C + retlw 0 + +; INCH_N is from "PIC Software UART Routines" +; John Massa, Datadog Systems (C) 2005 + +; ******************************************************************** +; INCH_N +; THIS ROUTINE INPUTS RS232 DATA USING AN INVERTER, LIKE THE MAX232. +; THIS ROUTINE USES A 8-DATA BIT PER CHARACTER PROTOCOL +; GPIO,0 = RX (MARK = 1, SPACE = 0). +; TO RECIEVE A CHARACTER, CALL inch_n, THE RECEIVED CHARACTER IS PLACED +; IN THE REG 'W' AND IN THE REG 'SERBUF'. +; THE RECEIVED CHARACTER WILL ECHO IF 'RETLW 0' IS REM-ED OUT. +; VARIABLES USED: REG 'TEMP' AND REG 'SERBUF' BOTH VARIABLES ARE +; SHARED WITH THE 'outch_n' ROUTINE. +; ROUTINES CALLED: 'half_baud'AND 'baud' TO SET THE BAUD-RATE +; ******************************************************************** + +; Modified by David Rowe May 2008 to combine a 1 second delay with +; character reception. + +inch_n_delay + + ; clear previous rx char + + movlw '-' + movwf SERBUFI + + ; init delay loop for 1999996 cycles + + bsf FSR,5 ; d1, d2, d3 in Bank 1 (groan) + movlw 0x11 + movwf d1 + movlw 0x5D + movwf d2 + movlw 0x05 + movwf d3 + +wait_for_start + bcf FSR,5 ; just in case goto below fires + btfss GPIO,3 ; SKIP UNLESS WE GET A START BIT = 1 (A "MARK") + goto start_serial ; start bit - process character + + ; process delay loop while we look for start bit + + bsf FSR,5 + decfsz d1, f + goto $+2 + decfsz d2, f + goto $+2 + decfsz d3, f + goto wait_for_start + + ; delay finished + + bcf FSR,5 + retlw 0 + +start_serial + bsf GPIO,5 + bcf GPIO,5 + + movlw 8 ; START SERIAL INPUT SEQUENCE + movwf TEMP ; COLLECT 8 DATA BITS + clrf SERBUFI ; CLEAR SERIAL CHARACTER BUFFER + call half_baud ; DELAY FOR ONE HALF BAUD TIME + btfsc GPIO,3 ; FALL THRU IF START BIT STILL = 1 (A "MARK") + goto wait_for_start ; ELSE IT WAS JUST A NOISE SPIKE, KEEP LOOKING +inch_n1 + call baud ; DELAY ONE BAUD-BIT TIME ( = 1/BAUD-RATE) + bcf STATUS,0 ; CLEAR THE CARRY BIT + rrf SERBUFI,F ; ROTATE CRY -> MSB, ROTATE MSB RIGHT + btfsc GPIO,3 ; IS IT A "MARK" ? + bsf SERBUFI,7 ; ...SKIP IF YES, ELSE SET BIT TO LOGIC '1' + decfsz TEMP,F ; EIGHT COUNTS YET? + goto inch_n1 ; ...NO, GET ANOTHER BIT + call baud ; DELAY FOR THE STOP BIT + movf SERBUFI,W ; PUT THE RECEIVED CHARACTER IN REG 'W' + + ; process received character, this can be considered an "event + ; handler" for rx-chars. We expect either a 'w' to reset the + ; watchdog or a tightly defined sequence of sleep characters. + + movlw 'w' + subwf SERBUFI,0 ; is it a 'w' for watchdog reset? + btfss STATUS,Z ; skip if received char matches + goto handle_sleepin ; only process sleep input if not a 'w' + + ; handle 'w' input + + ; Note if we are sleeping or WD is firing we will keep power + ; off and receiving 'w' will have no effect. Unlikely unless + ; device sending rx chars is powered indepednantly (ie during + ; testing). + + movlw WD_TIMEOUT ; reset watchdog timer + movwf wd_timeout + + movlw '-' ; clear reboot flag + movwf restart_flag + + clrf sleep_state ; reset sleep state machine for good measure + clrf sleep_timeout ; just in case we get s-l-w-e-e-p or something + + goto wait_for_start + +handle_sleepin + call sleep_input + goto wait_for_start + +; OUTCH_N and BAUD are from "PIC Software UART Routines" +; John Massa, Datadog Systems (C) 2005 + +;********************************************************************* +; OUTCH_N +; THIS ROUTINE OUTPUTS RS232 DATA THROUGH AN INVERTER. +; THIS ROUTINE USES AN 8-DATA BIT PER CHARACTER PROTOCOL. +; TO PRINT A CHARACTER, LOAD BYTE INTO REG 'W' AND CALL outch_n. +; GPIO,1 = TX (MARK = 1, SPACE = 0) ; USE INVERTER ON THE OUTPUT +; VARIABLES USED: REG 'TEMP' AND SHARE REG 'SERBUF' WITH THE ROUTINE +; 'inch_n' +; CALLS THE ROUTINE 'baud' TO SET THE BAUD-RATE TIMING. +;********************************************************************* + +outch_n ; THIS ROUTINE USES 8 DATA BITS + movwf SERBUF ; SERBUF CONTAINS CHARACTER TO XMT + movlw 8 ; THE CHARACTER HAS 8 BITS + movwf TEMP + bcf GPIO,4 ; SET START-BIT TO A "SPACE" + call baud ; WAIT ONE BAUD TIME +outch_n1 + rrf SERBUF,F ; ROTATE THE FIRST BIT INTO CARRY + btfss STATUS,0 ; TEST THE CARRY BIT + bcf GPIO,4 ; IF BIT IS 0 SET OUTPUT PIN TO A "0" (SPACE) + btfsc STATUS,0 ; TEST THE CARRY BIT AGAIN + bsf GPIO,4 ; IF BIT IS 1 SET OUTPUT PIN TO A "1" (MARK) + call baud ; ONE BAUD-BIT DELAY + decfsz TEMP,F ; IF COUNT IS ZERO THEN XMIT A STOP BIT + goto outch_n1 ; ...ELSE XMIT NEXT BIT + rrf SERBUF,F ; ROTATE CARRY, GET THE MSB BACK INTO BIT 7 + bsf GPIO,4 ; SET PIN TO A 1 (A "MARK") FOR THE STOP BIT + call baud ; FIRST BAUD-BIT DELAY + call baud ; SECOND BAUD-BIT DELAY + retlw 0 ; RETURN WITH THE CHARACTER IN SERBUF + +; ******************************************************************** +; BAUD ROUTINE @ 4 MHz +; BAUD RATE: CONSTANT: +; 1200 Baud D'137' +; 2400 Baud D'68' +; 4800 Baud D'34' +; 9600 Baud D'16' +; 19200 Baud D'8' +; 38400 Baud and up - use 'NOP' delays +; VARIABLES USED: REG 'count' +; ROUTINES CALLED: NONE +; ******************************************************************** + +baud ; AT 2400 BAUD THE PERIOD IS 416.6 US + ; CLK = 4MHz + movlw D'68' ; 1 US (BAUD RATE CONSTANT) + movwf count ; 1 US +baud1 + decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) + goto baud1 ; 2 US + ; FALL THRU...AFTER 1+1+3x68+1 = 207 US +half_baud + movlw D'68' ; 1 US + movwf count ; 1 US +hbaud1 + decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) + goto hbaud1 ; 2 US + retlw 0 ; ...AFTER 1+1+3x68+1 = 207 US (X2=414 US) + +; http://www.piclist.com/techref/piclist/codegen/delay.htm +; Delay = 1 seconds +; Clock frequency = 8 MHz + +; Actual delay = 1 seconds = 2000000 cycles +; Error = 0 % + +delay + ;1999996 cycles + bsf FSR,5 + movlw 0x11 + movwf d1 + movlw 0x5D + movwf d2 + movlw 0x05 + movwf d3 +Delay_0 + decfsz d1, f + goto $+2 + decfsz d2, f + goto $+2 + decfsz d3, f + goto Delay_0 + + ;4 cycles + goto $+1 + goto $+1 + + bcf FSR,5 + retlw 0 + +; sleep input state machine +; +; we expect the chars s-l-e-e-p-x-y-z where xyz are digits +; if wrong char received reset +; if 5 sec timout between chars reset +; if xyz are not digits reset + +sleep_input + + ; big case statement to work out what state we are in + + movlw 0 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 's' + goto sleep_state_s + movlw 1 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'l' + goto sleep_state_l + movlw 2 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'e1' + goto sleep_state_e1 + movlw 3 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'e2' + goto sleep_state_e2 + movlw 4 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'p' + goto sleep_state_p + movlw 5 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'x' + goto sleep_state_x + movlw 6 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'y' + goto sleep_state_y + movlw 7 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'z' + goto sleep_state_z + + ; should never get here but just in case + + goto sleep_reset + + ; if we have rx-ed a 's' continue to next state +sleep_state_s + movlw 's' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 's' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'l' continue to next state +sleep_state_l + movlw 'l' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'l' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'e' continue to next state +sleep_state_e1 + movlw 'e' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'e' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'e' continue to next state +sleep_state_e2 + movlw 'e' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'e' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'p' continue to next state +sleep_state_p + movlw 'p' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'p' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_x + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if x <= 9 + bsf FSR,5 ; x is in bank 1 + movwf x + movlw d'10' + subwf x,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_y + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if y <= 9 + bsf FSR,5 ; y is in bank 1 + movwf y + movlw d'10' + subwf y,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_z + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if z <= 9 + bsf FSR,5 ; z is in bank 1 + movwf z + movlw d'10' + subwf z,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + + ; OK we made it! Lets go to SLEEP, ZZZZZzzzzzzzzzz + + clrf sleep_state + clrf sleep_timeout + movlw 1 + movwf sleeping + bcf GPIO,1 ; power switch off + + retlw 0 + + ; we bombed out in rx-ing sleep string +sleep_reset + clrf sleep_state + clrf sleep_timeout + retlw 0 + + ; increment to next state, and reset sleep timeout +sleep_cont + incf sleep_state,1 + movlw SLEEP_TIMEOUT + movwf sleep_timeout + retlw 0 + +; START MAIN LOOP ----------------------------------------------- + +main + call inch_n_delay ; RS232 RX and 1 second delay + + ; sample V, I, and print if we received a 'w' or a ' ' + + movlw 'w' + subwf SERBUFI,0 + btfsc STATUS,Z ; skip if SERBUFI != 'w' + goto sample + + movlw '.' + subwf SERBUFI,0 + btfss STATUS,Z ; skip if SERBUFI == ' ' + goto no_print + + ; sample AN[0] (voltage) +sample + movlw b'10110001' + movwf ADCON0 + bsf ADCON0,1 ; start A/D conversion +wait_adc_v + btfsc ADCON0,1 ; skip if A/D conversion finished + goto wait_adc_v + + ; print 'wispcar' to get host to call script called wispcar. + ; This script can then parse wispcar output + + movlw 'w' + call outch_n + movlw 'i' + call outch_n + movlw 's' + call outch_n + movlw 'p' + call outch_n + movlw 'c' + call outch_n + movlw 'a' + call outch_n + movlw 'r' + call outch_n + movlw ' ' + call outch_n + + ; print voltage to RS232 + + movf ADRES, 0 + movwf BIN + call BIN2BCD ; convert voltage to decimal ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print space + + movlw ' ' + call outch_n + + ; sample AN[1] (current) + + movlw b'10111001' + movwf ADCON0 + bsf ADCON0,1 ; start A/D conversion +wait_adc_i + btfsc ADCON0,1 ; skip if A/D conversion finished + goto wait_adc_i + + ; print current to RS232 + + movf ADRES, 0 + movwf BIN + call BIN2BCD ; convert current to decimal & ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print rx char + + movlw ' ' + call outch_n + movf SERBUFI, 0 + call outch_n + + ; print rx char in dec + + movlw ' ' + call outch_n + movf SERBUFI, 0 + movwf BIN + call BIN2BCD ; convert rx char to decimal & ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print wd_timeout in dec + + movlw ' ' + call outch_n + movf wd_timeout, 0 + movwf BIN + call BIN2BCD + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print wd_fire in dec + + movlw ' ' + call outch_n + movf wd_fire, 0 + movwf BIN + call BIN2BCD + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print sleep_state + + movlw ' ' + call outch_n + movlw '0' + addwf sleep_state,0 + call outch_n + + ; print sleep timer in dec + + movlw ' ' + call outch_n + movlw '0' ; print x + bsf FSR,5 + addwf x,0 + bcf FSR,5 + call outch_n + movlw '0' ; print y + bsf FSR,5 + addwf y,0 + bcf FSR,5 + call outch_n + movlw '0' ; print z + bsf FSR,5 + addwf z,0 + bcf FSR,5 + call outch_n + + ; print restart_flag + + movlw ' ' + call outch_n + movf restart_flag, 0 + call outch_n + + ; print CR-LF + + movlw '\r' + call outch_n + movlw '\n' + call outch_n + +no_print + ; has watchdog fired (wd_timeout == 0) ? + + movf wd_timeout,1 + btfsc STATUS,Z ; skip if not fired + goto watchdog_firing ; Yes? Then goto watchdog firing code + + ; are we sleeping (sleeping == 1)? + + movf sleeping,1 + btfss STATUS,Z ; skip if not sleeping + goto snooze ; Yes? Then goto sleeping code + + ; No? Then count down watchdog + + movlw 1 + subwf wd_timeout,1 + + ; Has watchdog just fired (wd_timeout == 0)? + + btfss STATUS,Z ; skip if wd_countdown is zero + goto dec_sleeptimeout ; No - continue + + ; Yes - start watchdog firing code + + bcf GPIO,1 ; PowerSwitch Off + movlw WD_FIRE + movwf wd_fire + goto main + +dec_sleeptimeout + ; has sleep state machine accepted a rx char? + + movf sleep_state,1 + btfsc STATUS,Z + goto main ; No? Then continue processing + + decfsz sleep_timeout,1 + goto main + + ; sleep state machine timeout, reset state machine + clrf sleep_state + goto main + + ; watchdog firing code + +watchdog_firing + + movlw 1 + subwf wd_fire,1 + + ; watchdog firing complete? (wd_fire == 0)? + + btfss STATUS,Z ; skip if wd_fire is zero + goto main ; No - continue + + ; Yes - reset watchdog + + bsf GPIO,1 ; PowerSwitch On + movlw WD_TIMEOUT + movwf wd_timeout + + ; Indicate WD has fired since last 'w' sent by host. A rx of + ; 'w' resets this flag. + + movlw WD_FLAG + movwf restart_flag + + goto main + + ; sleeping code + ; sleep for xyz seconds, need to count down in decimal +snooze + ; 3 digit decimal count down timer xyz, e.g. 999, 998,...001,000 + ; it's time's like these I wonder why I volunteered for this project!! :-) + ; see countdown.c for C version of this algorithm + + bsf FSR,5 + movf z,1 + btfss STATUS,Z + goto z_not_zero + movf y,1 + btfss STATUS,Z + goto y_not_zero + movf x,1 + btfss STATUS,Z + goto x_not_zero + + ; x=y=z=0 so we are finished + + bcf FSR,5 + goto sleep_finished + +z_not_zero + decf z,1 + goto continue_sleep + +y_not_zero + decf y,1 + movlw 9 + movwf z + goto continue_sleep + +x_not_zero + decf x,1 + movlw 9 + movwf y + movwf z + goto continue_sleep + + ; sleep finished + +sleep_finished + bsf GPIO,1 ; PowerSwitch On + movlw WD_TIMEOUT ; reset watchdog for good measure + movwf wd_timeout + clrf wd_fire + clrf sleep_timeout ; clear sleep timeout counter + clrf sleeping ; clear sleep flag + + ; Indicate we have just woken up from a sleep. A rx of 'w' + ; resets this. + + movlw SLEEP_FLAG + movwf restart_flag + goto main + +continue_sleep + bcf FSR,5 + goto main + +; END MAIN LOOP ----------------------------------------------- + + end + + diff --git a/attic/wispcar/wispcar.sch b/attic/wispcar/wispcar.sch new file mode 100644 index 00000000..db323aba --- /dev/null +++ b/attic/wispcar/wispcar.sch @@ -0,0 +1,328 @@ +v 20060906 1 +C 50900 31400 1 90 0 bf-capacitor-1.sym +{ +T 50400 31900 5 10 1 1 180 0 1 +value=100nF 100V +} +C 50800 35800 1 0 0 bf-resistor-1.sym +{ +T 51000 36300 5 10 1 1 0 0 1 +refdes=R1 +T 51000 36100 5 10 1 1 0 0 1 +value=100k +} +C 43000 23300 0 0 0 title-bordered-C.sym +B 43500 23800 6800 800 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +T 43600 24000 9 10 1 0 0 0 1 +Licensed under the TAPR Open Hardware License (www.tapr.org/OHL) +T 43600 24300 9 10 1 0 0 0 1 +COPYRIGHT DAVID ROWE 2008 +T 58000 24500 9 10 1 0 0 0 1 +Wifi Station Power Controller And Reporter - WiSPCaR +T 62000 23600 9 10 1 0 0 0 1 +David Rowe +T 62000 23900 9 10 1 0 0 0 1 +0.1 +T 58500 23600 9 10 1 0 0 0 1 +1 +T 59800 23600 9 10 1 0 0 0 1 +1 +T 58000 23900 9 10 1 0 0 0 1 +wispcar.sch +C 58000 35600 1 180 1 lm324-1.sym +{ +T 57525 35650 5 8 1 1 180 6 1 +device=LM324 +T 57500 35900 5 10 1 1 180 6 1 +refdes=U2 +T 58000 35600 5 10 0 0 180 6 1 +slot=1 +} +C 56300 28300 1 0 0 lm324-1.sym +{ +T 57125 28450 5 8 0 0 0 0 1 +device=LM324 +T 57000 29100 5 10 1 1 0 0 1 +refdes=U2 +T 56300 28300 5 10 0 0 0 0 1 +slot=2 +} +C 56300 29300 1 0 0 lm324-1.sym +{ +T 57125 29450 5 8 0 0 0 0 1 +device=LM324 +T 57000 29900 5 10 1 1 0 0 1 +refdes=U2 +T 56300 29300 5 10 0 0 0 0 1 +slot=3 +} +C 56300 27200 1 0 0 lm324-1.sym +{ +T 57125 27350 5 8 0 0 0 0 1 +device=LM324 +T 57000 28100 5 10 1 1 0 0 1 +refdes=U2 +T 56300 27200 5 10 0 0 0 0 1 +slot=4 +} +C 50800 31700 1 0 0 LM78L05.sym +{ +T 52400 33000 5 10 0 0 0 0 1 +device=78L05 +T 51300 31800 5 10 1 1 0 6 1 +refdes=U3 +} +C 54800 30700 1 0 0 PC12F510.sym +{ +T 57200 31500 5 10 0 0 0 0 1 +device=PIC12F510 +T 57200 31200 5 10 0 0 0 0 1 +footprint=DIP8 +T 55350 32650 5 10 1 1 0 6 1 +refdes=U1 +} +C 52200 33800 1 0 1 npn-2.sym +{ +T 51600 34300 5 10 0 0 0 6 1 +device=NPN_TRANSISTOR +T 52400 34000 5 10 1 1 0 6 1 +refdes=Q2 +T 52100 33800 5 10 1 1 0 0 1 +value=BC548 +} +B 51400 28300 1000 1000 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +B 51500 29300 800 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +V 51900 29600 100 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +B 51500 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +B 52200 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +B 51850 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +T 52350 30050 9 10 1 0 0 0 1 +IRF9540 +T 52900 28450 9 10 1 0 0 0 1 +BC548 +A 53200 27900 400 0 179 3 0 0 0 -1 -1 +L 52800 27900 52800 27700 3 0 0 0 -1 -1 +L 53600 27900 53600 27700 3 0 0 0 -1 -1 +L 52800 27700 53600 27700 3 0 0 0 -1 -1 +V 53000 27900 52 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +V 53200 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +V 53400 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +T 52950 27450 9 10 1 0 0 0 1 +E +T 53150 27450 9 10 1 0 0 0 1 +B +T 53350 27450 9 10 1 0 0 0 1 +C +T 51500 27450 9 10 1 0 0 0 1 +G +T 51850 27450 9 10 1 0 0 0 1 +D +T 52200 27450 9 10 1 0 0 0 1 +S +A 54350 27900 400 0 179 3 0 0 0 -1 -1 +L 53950 27900 53950 27700 3 0 0 0 -1 -1 +L 54750 27900 54750 27700 3 0 0 0 -1 -1 +L 53950 27700 54750 27700 3 0 0 0 -1 -1 +V 54150 27900 52 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +V 54350 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +V 54550 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 +T 54050 28450 9 10 1 0 0 0 1 +78L05 +T 53900 27450 9 10 1 0 0 0 1 +VIN +T 54150 27200 9 10 1 0 0 0 1 +GND +T 54500 27450 9 10 1 0 0 0 1 +VOUT +T 51700 28750 9 10 1 0 0 0 1 +TOP +N 50300 36700 51500 36700 4 +{ +T 50200 36800 5 10 1 1 0 0 1 +netname=VBAT_IN +} +N 50700 35900 50800 35900 4 +C 51600 35700 1 270 0 bf-resistor-1.sym +{ +T 51100 35400 5 10 1 1 0 0 1 +refdes=R2 +T 51100 35200 5 10 1 1 0 0 1 +value=100k +} +N 51700 36200 51700 35700 4 +N 50700 32300 50700 36700 4 +N 50700 32300 50800 32300 4 +C 50600 31100 1 0 0 gnd-1.sym +C 52600 31400 1 90 0 bf-capacitor-1.sym +{ +T 52900 31200 5 10 1 1 180 0 1 +value=100nF 10V +} +N 50700 31400 52400 31400 4 +N 51600 31700 51600 31400 4 +C 51600 33100 1 0 0 gnd-1.sym +C 52900 34200 1 0 0 bf-resistor-1.sym +{ +T 53100 34700 5 10 1 1 0 0 1 +refdes=R4 +T 53100 34500 5 10 1 1 0 0 1 +value=10k +} +C 52500 35700 1 270 0 bf-resistor-1.sym +{ +T 52000 35400 5 10 1 1 0 0 1 +refdes=R3 +T 52000 35200 5 10 1 1 0 0 1 +value=100k +} +C 52400 35700 1 0 0 bf-5V-plus-1.sym +C 52600 32300 1 0 0 bf-5V-plus-1.sym +N 52400 32300 54800 32300 4 +N 52200 34300 52900 34300 4 +N 52600 34800 52600 34300 4 +T 51200 37300 9 10 1 0 0 0 1 +POWER SWITCH +N 52300 36700 55000 36700 4 +T 56300 37300 9 10 1 0 0 0 1 +CURRENT SENSOR +C 55000 36600 1 0 0 bf-resistor-1.sym +{ +T 55300 36900 5 10 1 1 0 0 1 +refdes=R5 +T 55100 36400 5 10 1 1 0 0 1 +value=0.1R 5W +} +C 54400 36300 1 270 0 bf-resistor-1.sym +{ +T 54700 36000 5 10 1 1 0 0 1 +refdes=R6 +T 54700 35800 5 10 1 1 0 0 1 +value=100k 1% +} +C 54400 34900 1 270 0 bf-resistor-1.sym +{ +T 54700 34600 5 10 1 1 0 0 1 +refdes=R7 +T 54700 34400 5 10 1 1 0 0 1 +value=10k 1% +} +C 56400 36300 1 270 0 bf-resistor-1.sym +{ +T 56700 36400 5 10 1 1 0 0 1 +refdes=R8 +T 56700 36200 5 10 1 1 0 0 1 +value=100k 1% +} +C 56400 34900 1 270 0 bf-resistor-1.sym +{ +T 56700 34600 5 10 1 1 0 0 1 +refdes=R9 +T 56700 34400 5 10 1 1 0 0 1 +value=10k 1% +} +C 57500 34900 1 270 0 bf-resistor-1.sym +{ +T 57800 34100 5 10 1 1 0 0 1 +refdes=R10 +T 57800 33900 5 10 1 1 0 0 1 +value=1M 1% +} +C 58000 36000 1 0 0 bf-resistor-1.sym +{ +T 58300 36500 5 10 1 1 0 0 1 +refdes=R11 +T 58300 36300 5 10 1 1 0 0 1 +value=1M 1% +} +N 54500 36700 54500 36300 4 +N 54500 35400 54500 34900 4 +C 58600 35900 1 180 0 gnd-1.sym +N 56500 35400 56500 34900 4 +N 56500 36700 56500 36300 4 +N 55900 36700 60300 36700 4 +{ +T 59300 36800 5 10 1 1 0 0 1 +netname=VBAT_OUT +} +N 56500 35400 58000 35400 4 +N 58000 36100 56900 36100 4 +N 56900 36100 56900 35400 4 +N 58000 35000 54500 35000 4 +N 57600 35000 57600 34900 4 +C 58700 34800 1 180 0 bf-5V-plus-1.sym +C 57500 33700 1 0 0 gnd-1.sym +N 57600 34000 54500 34000 4 +N 58900 36100 59200 36100 4 +N 59200 36100 59200 35200 4 +C 56900 32200 1 90 0 gnd-1.sym +N 54800 31500 53200 31500 4 +{ +T 53200 31600 5 10 1 1 0 0 1 +netname=RS232 TX (OUT) +} +N 54800 31100 53200 31100 4 +{ +T 53200 31200 5 10 1 1 0 0 1 +netname=RS232 RX (IN) +} +N 54800 31900 53200 31900 4 +{ +T 53200 32000 5 10 1 1 0 0 1 +netname=SPARE I/O +} +N 58200 31900 56600 31900 4 +{ +T 56600 32000 5 10 1 1 0 0 1 +netname=Vsense (IN) +} +N 53800 34300 54000 34300 4 +N 54000 34300 54000 33400 4 +N 54000 33400 58500 33400 4 +N 58500 31500 58500 33400 4 +N 56600 31500 58500 31500 4 +{ +T 56600 31600 5 10 1 1 0 0 1 +netname=PowerSwitch (OUT) +} +N 56300 29900 56300 27200 4 +C 56200 26900 1 0 0 gnd-1.sym +N 59000 35200 60300 35200 4 +{ +T 59600 35300 5 10 1 1 0 0 1 +netname=Isense +} +N 60300 35200 60300 31100 4 +N 56600 31100 60300 31100 4 +{ +T 56600 31200 5 10 1 1 0 0 1 +netname=Isense (IN) +} +N 58200 33000 58200 31900 4 +C 51500 36200 1 270 1 pmos-wispcar.sym +{ +T 52000 36800 5 10 0 0 90 2 1 +device=PMOS_TRANSISTOR +T 51700 36800 5 10 1 1 180 2 1 +refdes=Q1 +T 52100 36800 5 10 1 1 0 0 1 +value=IRF9540 +} +C 51900 33300 1 0 0 bf-resistor-1.sym +{ +T 53000 33500 5 10 1 1 0 0 1 +refdes=R13 +T 53000 33300 5 10 1 1 0 0 1 +value=10k +} +N 51700 33800 51700 33400 4 +N 51700 33400 51900 33400 4 +N 52900 33000 52900 33400 4 +N 52900 33400 52800 33400 4 +N 51600 33000 58200 33000 4 +C 50700 32900 1 0 0 bf-resistor-1.sym +{ +T 50900 33400 5 10 1 1 0 0 1 +refdes=R12 +T 50900 33200 5 10 1 1 0 0 1 +value=100k +} diff --git a/attic/wispcar/wispcar_sch.pdf b/attic/wispcar/wispcar_sch.pdf new file mode 100644 index 00000000..621c0ca0 Binary files /dev/null and b/attic/wispcar/wispcar_sch.pdf differ diff --git a/attic/wispcar/wispcarb.asm b/attic/wispcar/wispcarb.asm new file mode 100755 index 00000000..aec22c43 --- /dev/null +++ b/attic/wispcar/wispcarb.asm @@ -0,0 +1,1020 @@ +; wispcarb.asm +; David Rowe June 2009 +; +; WISPCAR modified for EV battery testing. When watchdog fires PowerSwitch +; (pin 6) stays off until the host sends a "w". This switches off current +; to the battery under test if the host side dies. This mod is just a hack +; for now. +; +; +; PIC12F510 Assembler program, MPLAB V8.10 IDE used to build. +; +; ******************************************************** +; * Wifi Station Power Controller And Reporter - WiSPCaR * +; ******************************************************** +; +;--------------------------------------------------------------------- +; Copyright (C) 2008 David Rowe +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; 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. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +; USA +;--------------------------------------------------------------------- +; +; FUNCTIONS +; ========= +; +; 1/ Monitor Voltage +; 2/ Monitor Current +; 3/ Watchdog timer +; 4/ Sleep timer +; +; +; PINOUT +; ====== +; ____ ____ +; | \/ | +; Vcc --| 1 8 |-- GND +; | | +; Spare I/O --| 2 7 |-- Vsense (in) +; | | +; RS232 Tx (out) --| 3 6 |-- PowerSwitch (out) +; | | +; RS232 Rx (in) --| 4 5 |-- Isense (in) +; |__________| +; +; +; Pin | Function | PIC Name +; -----|-------------|--------- +; 2 | Spare I/O | GP5 +; 3 | RS232 Tx | GP4 +; 4 | RS232 Rx | GP3 +; 5 | Isense | AN2 +; 6 | PowerSwitch | GP1 +; 7 | Vsense | AN0 +; +; +; PIC PROGRAMMING OPTIONS +; ======================= +; +; 8MHz clock, MCLRE=I/O, INTOSC +; +; +; 4800 BAUD RS232 OUTPUT +; ====================== +; +; The following line is printed every time you send 'w' or '.', if you +; send nothing to wispcar it will remain silent. The specific chars +; minimise the chance of wispcar interfering with your boot loader. +; +; Name of script on host that parses this line +; | Vsense +; | | Isense +; | | | char received (ASCII) +; | | | | Last char received (decimal) +; | | | | | Watchdog timeout counter +; | | | | | | Watchdog fire counter +; | | | | | | | Sleep state machine state +; | | | | | | | | Sleep timeout counter +; | | | | | | | | | +; wispcar 040 031 - 032 012 000 0 000 w---reason for last restart +; b - Wispcar (re)booted +; w - watchdog timer fired +; s - we went to sleep +; - - restart flag reset +; +; COMMANDS +; ======== +; +; 1/ Send a 'w' every WD_TIMEOUT seconds to prevent Watchdog timer +; firing and cutting power. +; +; 2/ Send a '.' to report status without resetting watchdog. +; +; 3/ Send the string 'sleepxyz' to cut the power for xyz seconds, +; where x,y and z are digits in the range 0-9. If any part of the +; string is invalid it will be ignored. Wait 5 seconds and start +; again. +; +; 4/ Wispcar cannot rx and tx RS232 at the same time. Wait until after +; the current output has finished to send the next command. It is best to +; wait until just after the output line is received by the host, then +; send your command. If the command (such as sleep) gets messed up, +; just wait 5 seconds and wispcar will reset it's internal state +; machine. You can then try again. +; +; 4/ The final field is reset to a space when a 'w' is sent to +; Wispcar. This field lets the host know just _why_ it was rebooted. + + +#include + +; VARIABLES --------------------------------------------------------------------- + +TEMP equ 0x10 +SERBUF equ 0x11 ; RS232 char to transmit +count equ 0x12 ; temp reg used by "BIN2BCD" and "baud" routines +BIN equ 0x13 +huns equ 0x14 +tens equ 0x15 +ones equ 0x16 +thirty equ 0x17 ; constant set to (guess what) 30 +SERBUFI equ 0x18 ; last RS232 character we received +wd_timeout equ 0x19 ; current watchdog timer value (in secs) + ; when this hits zero we turn the power off +wd_fire equ 0x1a ; count down timer when watchdog fires (in secs) +restart_flag equ 0x1b ; tells host why we just restarted (WD or sleep) + +sleep_state equ 0x1c +sleep_timeout equ 0x1d ; current value of sleep time out (in secs) + ; measures time between rx-ed chars in + ; s-l-e-e-p-x-y-z sequence. + ; If this hits zero (like s-l- (BIG GAP)) + ; we assume sleep command + ; was invalid and we reset the input state machine + + ; three digit sleep time (up to 999 secs) + ; these count down to zero while we are sleeping + ; when count down hits 0 power is switched back on + +sleeping equ 0x1e ; asserted if we are sleeping (power off) + +; following variables are in bank1, which makes life difficult.... + +d1 equ 0x10 +d2 equ 0x11 +d3 equ 0x12 + +x equ 0x13 ; sleep time (hundreds of secs) +y equ 0x14 ; sleep time (tens of secs) +z equ 0x15 ; sleep time (secs) + +; CONSTANTS --------------------------------------------------------------------- + +WD_TIMEOUT equ d'18' ; watchdog timeout in seconds +WD_FIRE equ d'5' ; watchdog firing time in seconds + ; how long power is cut off to host + +SLEEP_TIMEOUT equ d'5' ; timeout between rx-ed chars in sleep input + ; sequence. + +; Values for restart_flag - tell host why we just cut power after we woke up + +BOOT_FLAG equ 'b' ; Wispcar just rebooted +WD_FLAG equ 'w' ; Watchdog fired +SLEEP_FLAG equ 's' ; We slept + +; START PROGRAM ---------------------------------------------------------------- + +; set up osc cal (temp code just for experimenting) +; TODO - FIX ME for general case + + movlw 16 + movwf OSCCAL + +; configure AN[1:0] as analog inputs + + movlw b'10110001' + movwf ADCON0 + +; configure GP[3] as digital input (RS232 RX) +; configure GP[4] as digital output (RS232 TX) +; configure GP[1] as digital output (PowerSwitch) + +; disble the comparitor so we can use GP[1] + + bcf CM1CON0,3 + + ; set up GPIO directions + + movlw b'00001101' + tris GPIO + +; turn on PowerSwitch + + bsf GPIO,1 + +; set up a convenient constant + + movlw h'30' + movwf thirty + +; init watchdog + + movlw WD_TIMEOUT + movwf wd_timeout + clrf wd_fire + +; init sleep + + clrf sleep_state + clrf sleeping + clrf sleep_timeout + bsf FSR,5 ; x,y,z are in bank 1 (grumble) + clrf x + clrf y + clrf z + bcf FSR,5 ; x,y,z are in bank 1 (grumble) + +; init restart_flag + + movlw BOOT_FLAG + movwf restart_flag + + goto main + +; START FUNCTIONS ------------------------------------------------------------ + +; BIN2BCD +; +; Convert 8 bit value in BIN to a 3 digit decimal value. +; +; in.......: BIN +; out......: huns, tens, ones +; Reference: http://www.piclist.com/techref/microchip/math/radix/b2a-8b3d-ab.htm +; +; Uses temp reg 'count' + +; uses ADD-3 algorithm + +BIN2BCD + movlw 8 + movwf count + clrf huns + clrf tens + clrf ones +BCDADD3 + movlw 5 + subwf huns, 0 + btfsc STATUS, C + CALL ADD3HUNS + + movlw 5 + subwf tens, 0 + btfsc STATUS, C + CALL ADD3TENS + + movlw 5 + subwf ones, 0 + btfsc STATUS, C + CALL ADD3ONES + + decf count, 1 + bcf STATUS, C + rlf BIN, 1 + rlf ones, 1 + btfsc ones,4 ; + CALL CARRYONES + rlf tens, 1 + + btfsc tens,4 ; + CALL CARRYTENS + rlf huns,1 + bcf STATUS, C + + movf count, 0 + btfss STATUS, Z + GOTO BCDADD3 + + movf huns, 0 ; add ASCII Offset + addwf thirty, 0 + movwf huns + + movf tens, 0 ; add ASCII Offset + addwf thirty, 0 + movwf tens + + movf ones, 0 ; add ASCII Offset + addwf thirty, 0 + movwf ones + + retlw 0 + +ADD3HUNS + movlw 3 + addwf huns,1 + retlw 0 + +ADD3TENS + movlw 3 + addwf tens,1 + retlw 0 + +ADD3ONES + movlw 3 + addwf ones,1 + retlw 0 + +CARRYONES + bcf ones, 4 + bsf STATUS, C + retlw 0 + +CARRYTENS + bcf tens, 4 + bsf STATUS, C + retlw 0 + +; INCH_N is from "PIC Software UART Routines" +; John Massa, Datadog Systems (C) 2005 + +; ******************************************************************** +; INCH_N +; THIS ROUTINE INPUTS RS232 DATA USING AN INVERTER, LIKE THE MAX232. +; THIS ROUTINE USES A 8-DATA BIT PER CHARACTER PROTOCOL +; GPIO,0 = RX (MARK = 1, SPACE = 0). +; TO RECIEVE A CHARACTER, CALL inch_n, THE RECEIVED CHARACTER IS PLACED +; IN THE REG 'W' AND IN THE REG 'SERBUF'. +; THE RECEIVED CHARACTER WILL ECHO IF 'RETLW 0' IS REM-ED OUT. +; VARIABLES USED: REG 'TEMP' AND REG 'SERBUF' BOTH VARIABLES ARE +; SHARED WITH THE 'outch_n' ROUTINE. +; ROUTINES CALLED: 'half_baud'AND 'baud' TO SET THE BAUD-RATE +; ******************************************************************** + +; Modified by David Rowe May 2008 to combine a 1 second delay with +; character reception. + +inch_n_delay + + ; clear previous rx char + + movlw '-' + movwf SERBUFI + + ; init delay loop for 1999996 cycles + + bsf FSR,5 ; d1, d2, d3 in Bank 1 (groan) + movlw 0x11 + movwf d1 + movlw 0x5D + movwf d2 + movlw 0x05 + movwf d3 + +wait_for_start + bcf FSR,5 ; just in case goto below fires + btfss GPIO,3 ; SKIP UNLESS WE GET A START BIT = 1 (A "MARK") + goto start_serial ; start bit - process character + + ; process delay loop while we look for start bit + + bsf FSR,5 + decfsz d1, f + goto $+2 + decfsz d2, f + goto $+2 + decfsz d3, f + goto wait_for_start + + ; delay finished + + bcf FSR,5 + retlw 0 + +start_serial + bsf GPIO,5 + bcf GPIO,5 + + movlw 8 ; START SERIAL INPUT SEQUENCE + movwf TEMP ; COLLECT 8 DATA BITS + clrf SERBUFI ; CLEAR SERIAL CHARACTER BUFFER + call half_baud ; DELAY FOR ONE HALF BAUD TIME + btfsc GPIO,3 ; FALL THRU IF START BIT STILL = 1 (A "MARK") + goto wait_for_start ; ELSE IT WAS JUST A NOISE SPIKE, KEEP LOOKING +inch_n1 + call baud ; DELAY ONE BAUD-BIT TIME ( = 1/BAUD-RATE) + bcf STATUS,0 ; CLEAR THE CARRY BIT + rrf SERBUFI,F ; ROTATE CRY -> MSB, ROTATE MSB RIGHT + btfsc GPIO,3 ; IS IT A "MARK" ? + bsf SERBUFI,7 ; ...SKIP IF YES, ELSE SET BIT TO LOGIC '1' + decfsz TEMP,F ; EIGHT COUNTS YET? + goto inch_n1 ; ...NO, GET ANOTHER BIT + call baud ; DELAY FOR THE STOP BIT + movf SERBUFI,W ; PUT THE RECEIVED CHARACTER IN REG 'W' + + ; process received character, this can be considered an "event + ; handler" for rx-chars. We expect either a 'w' to reset the + ; watchdog or a tightly defined sequence of sleep characters. + + movlw 'w' + subwf SERBUFI,0 ; is it a 'w' for watchdog reset? + btfss STATUS,Z ; skip if received char matches + goto handle_sleepin ; only process sleep input if not a 'w' + + ; handle 'w' input + + ; Note if we are sleeping or WD is firing we will keep power + ; off and receiving 'w' will have no effect. Unlikely unless + ; device sending rx chars is powered indepednantly (ie during + ; testing). + + movlw WD_TIMEOUT ; reset watchdog timer + movwf wd_timeout + + ; DR June 2009 - mods + bsf GPIO,1 + + movlw '-' ; clear reboot flag + movwf restart_flag + + clrf sleep_state ; reset sleep state machine for good measure + clrf sleep_timeout ; just in case we get s-l-w-e-e-p or something + + goto wait_for_start + +handle_sleepin + call sleep_input + goto wait_for_start + +; OUTCH_N and BAUD are from "PIC Software UART Routines" +; John Massa, Datadog Systems (C) 2005 + +;********************************************************************* +; OUTCH_N +; THIS ROUTINE OUTPUTS RS232 DATA THROUGH AN INVERTER. +; THIS ROUTINE USES AN 8-DATA BIT PER CHARACTER PROTOCOL. +; TO PRINT A CHARACTER, LOAD BYTE INTO REG 'W' AND CALL outch_n. +; GPIO,1 = TX (MARK = 1, SPACE = 0) ; USE INVERTER ON THE OUTPUT +; VARIABLES USED: REG 'TEMP' AND SHARE REG 'SERBUF' WITH THE ROUTINE +; 'inch_n' +; CALLS THE ROUTINE 'baud' TO SET THE BAUD-RATE TIMING. +;********************************************************************* + +outch_n ; THIS ROUTINE USES 8 DATA BITS + movwf SERBUF ; SERBUF CONTAINS CHARACTER TO XMT + movlw 8 ; THE CHARACTER HAS 8 BITS + movwf TEMP + bcf GPIO,4 ; SET START-BIT TO A "SPACE" + call baud ; WAIT ONE BAUD TIME +outch_n1 + rrf SERBUF,F ; ROTATE THE FIRST BIT INTO CARRY + btfss STATUS,0 ; TEST THE CARRY BIT + bcf GPIO,4 ; IF BIT IS 0 SET OUTPUT PIN TO A "0" (SPACE) + btfsc STATUS,0 ; TEST THE CARRY BIT AGAIN + bsf GPIO,4 ; IF BIT IS 1 SET OUTPUT PIN TO A "1" (MARK) + call baud ; ONE BAUD-BIT DELAY + decfsz TEMP,F ; IF COUNT IS ZERO THEN XMIT A STOP BIT + goto outch_n1 ; ...ELSE XMIT NEXT BIT + rrf SERBUF,F ; ROTATE CARRY, GET THE MSB BACK INTO BIT 7 + bsf GPIO,4 ; SET PIN TO A 1 (A "MARK") FOR THE STOP BIT + call baud ; FIRST BAUD-BIT DELAY + call baud ; SECOND BAUD-BIT DELAY + retlw 0 ; RETURN WITH THE CHARACTER IN SERBUF + +; ******************************************************************** +; BAUD ROUTINE @ 4 MHz +; BAUD RATE: CONSTANT: +; 1200 Baud D'137' +; 2400 Baud D'68' +; 4800 Baud D'34' +; 9600 Baud D'16' +; 19200 Baud D'8' +; 38400 Baud and up - use 'NOP' delays +; VARIABLES USED: REG 'count' +; ROUTINES CALLED: NONE +; ******************************************************************** + +baud ; AT 2400 BAUD THE PERIOD IS 416.6 US + ; CLK = 4MHz + movlw D'68' ; 1 US (BAUD RATE CONSTANT) + movwf count ; 1 US +baud1 + decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) + goto baud1 ; 2 US + ; FALL THRU...AFTER 1+1+3x68+1 = 207 US +half_baud + movlw D'68' ; 1 US + movwf count ; 1 US +hbaud1 + decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) + goto hbaud1 ; 2 US + retlw 0 ; ...AFTER 1+1+3x68+1 = 207 US (X2=414 US) + +; http://www.piclist.com/techref/piclist/codegen/delay.htm +; Delay = 1 seconds +; Clock frequency = 8 MHz + +; Actual delay = 1 seconds = 2000000 cycles +; Error = 0 % + +delay + ;1999996 cycles + bsf FSR,5 + movlw 0x11 + movwf d1 + movlw 0x5D + movwf d2 + movlw 0x05 + movwf d3 +Delay_0 + decfsz d1, f + goto $+2 + decfsz d2, f + goto $+2 + decfsz d3, f + goto Delay_0 + + ;4 cycles + goto $+1 + goto $+1 + + bcf FSR,5 + retlw 0 + +; sleep input state machine +; +; we expect the chars s-l-e-e-p-x-y-z where xyz are digits +; if wrong char received reset +; if 5 sec timout between chars reset +; if xyz are not digits reset + +sleep_input + + ; big case statement to work out what state we are in + + movlw 0 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 's' + goto sleep_state_s + movlw 1 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'l' + goto sleep_state_l + movlw 2 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'e1' + goto sleep_state_e1 + movlw 3 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'e2' + goto sleep_state_e2 + movlw 4 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'p' + goto sleep_state_p + movlw 5 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'x' + goto sleep_state_x + movlw 6 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'y' + goto sleep_state_y + movlw 7 + subwf sleep_state,0 + btfsc STATUS,Z ; Z set if in state 'z' + goto sleep_state_z + + ; should never get here but just in case + + goto sleep_reset + + ; if we have rx-ed a 's' continue to next state +sleep_state_s + movlw 's' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 's' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'l' continue to next state +sleep_state_l + movlw 'l' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'l' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'e' continue to next state +sleep_state_e1 + movlw 'e' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'e' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'e' continue to next state +sleep_state_e2 + movlw 'e' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'e' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a 'p' continue to next state +sleep_state_p + movlw 'p' + subwf SERBUFI,0 + btfss STATUS,Z ; Z set if we received a 'p' + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_x + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if x <= 9 + bsf FSR,5 ; x is in bank 1 + movwf x + movlw d'10' + subwf x,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_y + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if y <= 9 + bsf FSR,5 ; y is in bank 1 + movwf y + movlw d'10' + subwf y,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + goto sleep_cont + + ; if we have rx-ed a digit 0-9 continue to next state +sleep_state_z + + ; check if >= '0' + movlw '0' + subwf SERBUFI,0 + btfss STATUS,C ; C set if valid + goto sleep_reset + + ; check if z <= 9 + bsf FSR,5 ; z is in bank 1 + movwf z + movlw d'10' + subwf z,0 + bcf FSR,5 + btfsc STATUS,C ; C reset if valid + goto sleep_reset + + ; OK we made it! Lets go to SLEEP, ZZZZZzzzzzzzzzz + + clrf sleep_state + clrf sleep_timeout + movlw 1 + movwf sleeping + bcf GPIO,1 ; power switch off + + retlw 0 + + ; we bombed out in rx-ing sleep string +sleep_reset + clrf sleep_state + clrf sleep_timeout + retlw 0 + + ; increment to next state, and reset sleep timeout +sleep_cont + incf sleep_state,1 + movlw SLEEP_TIMEOUT + movwf sleep_timeout + retlw 0 + +; START MAIN LOOP ----------------------------------------------- + +main + call inch_n_delay ; RS232 RX and 1 second delay + + ; sample V, I, and print if we received a 'w' or a ' ' + + movlw 'w' + subwf SERBUFI,0 + btfsc STATUS,Z ; skip if SERBUFI != 'w' + goto sample + + movlw '.' + subwf SERBUFI,0 + btfss STATUS,Z ; skip if SERBUFI == ' ' + goto no_print + + ; sample AN[0] (voltage) +sample + movlw b'10110001' + movwf ADCON0 + bsf ADCON0,1 ; start A/D conversion +wait_adc_v + btfsc ADCON0,1 ; skip if A/D conversion finished + goto wait_adc_v + + ; print 'wispcar' to get host to call script called wispcar. + ; This script can then parse wispcar output + + movlw 'w' + call outch_n + movlw 'i' + call outch_n + movlw 's' + call outch_n + movlw 'p' + call outch_n + movlw 'c' + call outch_n + movlw 'a' + call outch_n + movlw 'r' + call outch_n + movlw ' ' + call outch_n + + ; print voltage to RS232 + + movf ADRES, 0 + movwf BIN + call BIN2BCD ; convert voltage to decimal ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print space + + movlw ' ' + call outch_n + + ; sample AN[1] (current) + + movlw b'10111001' + movwf ADCON0 + bsf ADCON0,1 ; start A/D conversion +wait_adc_i + btfsc ADCON0,1 ; skip if A/D conversion finished + goto wait_adc_i + + ; print current to RS232 + + movf ADRES, 0 + movwf BIN + call BIN2BCD ; convert current to decimal & ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print rx char + + movlw ' ' + call outch_n + movf SERBUFI, 0 + call outch_n + + ; print rx char in dec + + movlw ' ' + call outch_n + movf SERBUFI, 0 + movwf BIN + call BIN2BCD ; convert rx char to decimal & ASCII + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print wd_timeout in dec + + movlw ' ' + call outch_n + movf wd_timeout, 0 + movwf BIN + call BIN2BCD + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print wd_fire in dec + + movlw ' ' + call outch_n + movf wd_fire, 0 + movwf BIN + call BIN2BCD + + movf huns, 0 + call outch_n + movf tens, 0 + call outch_n + movf ones, 0 + call outch_n + + ; print sleep_state + + movlw ' ' + call outch_n + movlw '0' + addwf sleep_state,0 + call outch_n + + ; print sleep timer in dec + + movlw ' ' + call outch_n + movlw '0' ; print x + bsf FSR,5 + addwf x,0 + bcf FSR,5 + call outch_n + movlw '0' ; print y + bsf FSR,5 + addwf y,0 + bcf FSR,5 + call outch_n + movlw '0' ; print z + bsf FSR,5 + addwf z,0 + bcf FSR,5 + call outch_n + + ; print restart_flag + + movlw ' ' + call outch_n + movf restart_flag, 0 + call outch_n + + ; print CR-LF + + movlw '\r' + call outch_n + movlw '\n' + call outch_n + +no_print + ; has watchdog fired (wd_timeout == 0) ? + + movf wd_timeout,1 + btfsc STATUS,Z ; skip if not fired + goto watchdog_firing ; Yes? Then goto watchdog firing code + + ; are we sleeping (sleeping == 1)? + + movf sleeping,1 + btfss STATUS,Z ; skip if not sleeping + goto snooze ; Yes? Then goto sleeping code + + ; No? Then count down watchdog + + movlw 1 + subwf wd_timeout,1 + + ; Has watchdog just fired (wd_timeout == 0)? + + btfss STATUS,Z ; skip if wd_countdown is zero + goto dec_sleeptimeout ; No - continue + + ; Yes - start watchdog firing code + + bcf GPIO,1 ; PowerSwitch Off + movlw WD_FIRE + movwf wd_fire + goto main + +dec_sleeptimeout + ; has sleep state machine accepted a rx char? + + movf sleep_state,1 + btfsc STATUS,Z + goto main ; No? Then continue processing + + decfsz sleep_timeout,1 + goto main + + ; sleep state machine timeout, reset state machine + clrf sleep_state + goto main + + ; watchdog firing code + +watchdog_firing + + movlw 1 + + ; DR June 2009 - make watchdog fire forerver, cutting power + ; from battery indefinately until host returns + subwf wd_fire,0 + + ; watchdog firing complete? (wd_fire == 0)? + + btfss STATUS,Z ; skip if wd_fire is zero + goto main ; No - continue + + ; Yes - reset watchdog + + bsf GPIO,1 ; PowerSwitch On + movlw WD_TIMEOUT + movwf wd_timeout + + ; Indicate WD has fired since last 'w' sent by host. A rx of + ; 'w' resets this flag. + + movlw WD_FLAG + movwf restart_flag + + goto main + + ; sleeping code + ; sleep for xyz seconds, need to count down in decimal +snooze + ; 3 digit decimal count down timer xyz, e.g. 999, 998,...001,000 + ; it's time's like these I wonder why I volunteered for this project!! :-) + ; see countdown.c for C version of this algorithm + + bsf FSR,5 + movf z,1 + btfss STATUS,Z + goto z_not_zero + movf y,1 + btfss STATUS,Z + goto y_not_zero + movf x,1 + btfss STATUS,Z + goto x_not_zero + + ; x=y=z=0 so we are finished + + bcf FSR,5 + goto sleep_finished + +z_not_zero + decf z,1 + goto continue_sleep + +y_not_zero + decf y,1 + movlw 9 + movwf z + goto continue_sleep + +x_not_zero + decf x,1 + movlw 9 + movwf y + movwf z + goto continue_sleep + + ; sleep finished + +sleep_finished + bsf GPIO,1 ; PowerSwitch On + movlw WD_TIMEOUT ; reset watchdog for good measure + movwf wd_timeout + clrf wd_fire + clrf sleep_timeout ; clear sleep timeout counter + clrf sleeping ; clear sleep flag + + ; Indicate we have just woken up from a sleep. A rx of 'w' + ; resets this. + + movlw SLEEP_FLAG + movwf restart_flag + goto main + +continue_sleep + bcf FSR,5 + goto main + +; END MAIN LOOP ----------------------------------------------- + + end + + diff --git a/attic/wispcar/wispcarb_sch.pdf b/attic/wispcar/wispcarb_sch.pdf new file mode 100644 index 00000000..825386f8 Binary files /dev/null and b/attic/wispcar/wispcarb_sch.pdf differ diff --git a/wispcar/COPYING b/wispcar/COPYING deleted file mode 100644 index d60c31a9..00000000 --- a/wispcar/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/wispcar/LICENSE b/wispcar/LICENSE deleted file mode 100644 index 4b992c41..00000000 --- a/wispcar/LICENSE +++ /dev/null @@ -1,266 +0,0 @@ -The TAPR Open Hardware License -Version 1.0 (May 25, 2007) -Copyright 2007 TAPR – http://www.tapr.org/OHL - -PREAMBLE - -Open Hardware is a thing - a physical artifact, either electrical or -mechanical - whose design information is available to, and usable by, -the public in a way that allows anyone to make, modify, distribute, and -use that thing. In this preface, design information is called -"documentation" and things created from it are called "products." - -The TAPR Open Hardware License ("OHL") agreement provides a legal -framework for Open Hardware projects. It may be used for any kind of -product, be it a hammer or a computer motherboard, and is TAPR's -contribution to the community; anyone may use the OHL for their Open -Hardware project. - -Like the GNU General Public License, the OHL is designed to guarantee -your freedom to share and to create. It forbids anyone who receives -rights under the OHL to deny any other licensee those same rights to -copy, modify, and distribute documentation, and to make, use and -distribute products based on that documentation. - -Unlike the GPL, the OHL is not primarily a copyright license. While -copyright protects documentation from unauthorized copying, modification, -and distribution, it has little to do with your right to make, distribute, -or use a product based on that documentation. For better or worse, patents -play a significant role in those activities. Although it does not prohibit -anyone from patenting inventions embodied in an Open Hardware design, and -of course cannot prevent a third party from enforcing their patent rights, -those who benefit from an OHL design may not bring lawsuits claiming that -design infringes their patents or other intellectual property. - -The OHL addresses unique issues involved in the creation of tangible, -physical things, but does not cover software, firmware, or code loaded -into programmable devices. A copyright-oriented license such as the GPL -better suits these creations. - -How can you use the OHL, or a design based upon it? While the terms and -conditions below take precedence over this preamble, here is a summary: - -* You may modify the documentation and make products based upon it. - -* You may use products for any legal purpose without limitation. - -* You may distribute unmodified documentation, but you must include the -complete package as you received it. - -* You may distribute products you make to third parties, if you either -include the documentation on which the product is based, or make it -available without charge for at least three years to anyone who requests -it. - -* You may distribute modified documentation or products based on it, if -you: - * License your modifications under the OHL. - * Include those modifications, following the requirements stated - below. - * Attempt to send the modified documentation by email to any of the - developers who have provided their email address. This is a good - faith obligation – if the email fails, you need do nothing more - and may go on with your distribution. - -* If you create a design that you want to license under the OHL, you -should: - * Include this document in a file named LICENSE (with the appropriate - extension) that is included in the documentation package. - * If the file format allows, include a notice like “Licensed under - the TAPR Open Hardware License (www.tapr.org/OHL)” in each - documentation file. While not required, you should also include - this notice on printed circuit board artwork and the product - itself; if space is limited the notice can be shortened or - abbreviated. - * Include a copyright notice in each file and on printed circuit - board artwork. - * If you wish to be notified of modifications that others may make, - include your email address in a file named “CONTRIB.TXT” or - something similar. - -* Any time the OHL requires you to make documentation available to -others, you must include all the materials you received from the -upstream licensors. In addition, if you have modified the -documentation: - * You must identify the modifications in a text file (preferably - named "CHANGES.TXT") that you include with the documentation. - That file must also include a statement like "These modifications - are licensed under the TAPR Open Hardware License." - * You must include any new files you created, including any - manufacturing files (such as Gerber files) you create in the - course of making products. - * You must include both "before" and "after" versions of all files - you modified. - * You may include files in proprietary formats, but you must also - include open format versions (such as Gerber, ASCII, Postscript, - or PDF) if your tools can create them. - -TERMS AND CONDITIONS - -1. Introduction -1.1 This Agreement governs how you may use, copy, modify, and -distribute Documentation, and how you may make, have made, and -distribute Products based on that Documentation. As used in this -Agreement, to "distribute" Documentation means to directly or indirectly -make copies available to a third party, and to "distribute" Products -means to directly or indirectly give, loan, sell or otherwise transfer -them to a third party. - -1.2 "Documentation" includes: - (a) schematic diagrams; - (b) circuit or circuit board layouts, including Gerber and other - data files used for manufacture; - (c) mechanical drawings, including CAD, CAM, and other data files - used for manufacture; - (d) flow charts and descriptive text; and - (e) other explanatory material. -Documentation may be in any tangible or intangible form of expression, -including but not limited to computer files in open or proprietary -formats and representations on paper, film, or other media. - -1.3 "Products" include: - (a) circuit boards, mechanical assemblies, and other physical parts - and components; - (b) assembled or partially assembled units (including components - and subassemblies); and - (c) parts and components combined into kits intended for assembly - by others; -which are based in whole or in part on the Documentation. - -1.4 This Agreement applies to any Documentation which contains a -notice stating it is subject to the TAPR Open Hardware License, and to -all Products based in whole or in part on that Documentation. If -Documentation is distributed in an archive (such as a "zip" file) which -includes this document, all files in that archive are subject to this -Agreement unless they are specifically excluded. Each person who -contributes content to the Documentation is referred to in this -Agreement as a "Licensor." - -1.5 By (a) using, copying, modifying, or distributing the -Documentation, or (b) making or having Products made or distributing -them, you accept this Agreement, agree to comply with its terms, and -become a "Licensee." Any activity inconsistent with this Agreement will -automatically terminate your rights under it (including the immunities -from suit granted in Section 2), but the rights of others who have -received Documentation, or have obtained Products, directly or -indirectly from you will not be affected so long as they fully comply -with it themselves. - -1.6 This Agreement does not apply to software, firmware, or code -loaded into programmable devices which may be used in conjunction with -Documentation or Products. Such software is subject to the license -terms established by its copyright holder(s). - -2. Patents -2.1 Each Licensor grants you, every other Licensee, and every -possessor or user of Products a perpetual, worldwide, and royalty-free -immunity from suit under any patent, patent application, or other -intellectual property right which he or she controls, to the extent -necessary to make, have made, possess, use, and distribute Products. -This immunity does not extend to infringement arising from modifications -subsequently made by others. - -2.2 If you make or have Products made, or distribute Documentation -that you have modified, you grant every Licensor, every other Licensee, -and every possessor or user of Products a perpetual, worldwide, and -royalty-free immunity from suit under any patent, patent application, or -other intellectual property right which you control, to the extent -necessary to make, have made, possess, use, and distribute Products. -This immunity does not extend to infringement arising from modifications -subsequently made by others. - -2.3 To avoid doubt, providing Documentation to a third party for the -sole purpose of having that party make Products on your behalf is not -considered "distribution," and a third party's act of making Products -solely on your behalf does not cause that party to grant the immunity -described in the preceding paragraph. - -2.4 These grants of immunity are a material part of this Agreement, -and form a portion of the consideration given by each party to the -other. If any court judgment or legal agreement prevents you from -granting the immunity required by this Section, your rights under this -Agreement will terminate and you may no longer use, copy, modify or -distribute the Documentation, or make, have made, or distribute -Products. - -3. Modifications -You may modify the Documentation, and those modifications will become -part of the Documentation. They are subject to this Agreement, as are -Products based in whole or in part on them. If you distribute the -modified Documentation, or Products based in whole or in part upon it, -you must email the modified Documentation in a form compliant with -Section 4 to each Licensor who has provided an email address with the -Documentation. Attempting to send the email completes your obligations -under this Section and you need take no further action if any address -fails. - -4. Distributing Documentation -4.1 You may distribute unmodified copies of the Documentation in its -entirety in any medium, provided that you retain all copyright and other -notices (including references to this Agreement) included by each -Licensor, and include an unaltered copy of this Agreement. -4.2 You may distribute modified copies of the Documentation if you -comply with all the requirements of the preceding paragraph and: - (a) include a prominent notice in an ASCII or other open format - file identifying those elements of the Documentation that you - changed, and stating that the modifications are licensed under - the terms of this Agreement; - (b) include all new documentation files that you create, as well as - both the original and modified versions of each file you change - (files may be in your development tool's native file format, - but if reasonably possible, you must also include open format, - such as Gerber, ASCII, Postscript, or PDF, versions); - (c) do not change the terms of this Agreement with respect to - subsequent licensees; and - (d) if you make or have Products made, include in the Documentation - all elements reasonably required to permit others to make - Products, including Gerber, CAD/CAM and other files used for - manufacture. - -5. Making Products -5.1 You may use the Documentation to make or have Products made, -provided that each Product retains any notices included by the Licensor -(including, but not limited to, copyright notices on circuit boards). -5.2 You may distribute Products you make or have made, provided that -you include with each unit a copy of the Documentation in a form -consistent with Section 4. Alternatively, you may include either (i) an -offer valid for at least three years to provide that Documentation, at -no charge other than the reasonable cost of media and postage, to any -person who requests it; or (ii) a URL where that Documentation may be -downloaded, available for at least three years after you last distribute -the Product. - -6. NEW LICENSE VERSIONS -TAPR may publish updated versions of the OHL which retain the same -general provisions as the present version, but differ in detail to -address new problems or concerns, and carry a distinguishing version -number. If the Documentation specifies a version number which applies -to it and "any later version", you may choose either that version or any -later version published by TAPR. If the Documentation does not specify -a version number, you may choose any version ever published by TAPR. -TAPR owns the copyright to the OHL, but grants permission to any person -to copy, distribute, and use it in unmodified form. - -7. WARRANTY AND LIABILITY LIMITATIONS -7.1 THE DOCUMENTATION IS PROVIDED ON AN "AS-IS" BASIS WITHOUT -WARRANTY OF ANY KIND, TO THE EXTENT PERMITTED BY APPLICABLE LAW. ALL -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND -TITLE, ARE HEREBY EXPRESSLY DISCLAIMED. -7.2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL ANY LICENSOR -BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, CONSEQUENTIAL, PUNITIVE, OR EXEMPLARY DAMAGES ARISING OUT OF -THE USE OF, OR INABILITY TO USE, THE DOCUMENTATION OR PRODUCTS, -INCLUDING BUT NOT LIMITED TO CLAIMS OF INTELLECTUAL PROPERTY -INFRINGEMENT OR LOSS OF DATA, EVEN IF THAT PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -7.3 You agree that the foregoing limitations are reasonable due to -the non-financial nature of the transaction represented by this -Agreement, and acknowledge that were it not for these limitations, the -Licensor(s) would not be willing to make the Documentation available to -you. -7.4 You agree to defend, indemnify, and hold each Licensor harmless -from any claim brought by a third party alleging any defect in the -design, manufacture, or operation of any Product which you make, have -made, or distribute pursuant to this Agreement. - #### diff --git a/wispcar/Makefile b/wispcar/Makefile deleted file mode 100644 index 8f419eb5..00000000 --- a/wispcar/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# Makefile for Wispcar schematics -# Generates sch PDF -# Derived from the BlackfinOne Makefile - thanks Ivan - -SCH_FILES = wispcarb -PROJECT = wispcarb -REV := $(shell svn info | grep Revision | sed 's/Revision: //') - -SCHPS = $(addsuffix .ps,$(SCH_FILES)) -SCHPDF = $(addsuffix .sch.ps,$(SCH_FILES)) -PWD = $(shell pwd) - -PCB_PRINT_OPTIONS = --ps-color --media A4 - -all: schpdf - -%.ps: %.sch - gschem -o $@ -s gschem-print.scm $^ - -schpdf: $(SCHPS) - -rm *_sch.ps - # sed stuff enlarges gschem font which is too small for my eyes :-) - cat $(SCHPS) | sed 's/scalefont/1.5 mul scalefont/' > $(PROJECT)_sch.ps - ps2pdf $(PROJECT)_sch.ps $(PROJECT)_sch.pdf - diff --git a/wispcar/README b/wispcar/README deleted file mode 100644 index 2d8aede4..00000000 --- a/wispcar/README +++ /dev/null @@ -1,11 +0,0 @@ -wispcar README --------------- - -David Rowe 22 June 2009 - -stty is a WRT54GL OpenWRT binary utility some one had compiled on the web, used -for setting serial port speeds - -wispcar.asm is the original code as per the blog post: http://www.rowetel.com/blog/?p=68 - -wispcarb.asm has a mod to the watchdog timer to stay off, used for battery testing diff --git a/wispcar/batt_test.m b/wispcar/batt_test.m deleted file mode 100644 index 8e1d008b..00000000 --- a/wispcar/batt_test.m +++ /dev/null @@ -1,34 +0,0 @@ -% batt_test.m -% David Rowe 23 June 2009 -% Plot battery test results - -function batt_test(f,pngname) - d = load(f); - mins = d(:,1)*60 + d(:,2); - mins = mins - mins(1); - s = sprintf(';%s;',f); - plot(mins, 0.072*d(:,4) + 0.82,s); - xlabel('time (min)'); ylabel('V'); - axis([0 60 11 13]) - grid - - if (nargin == 2) - - % small image - - __gnuplot_set__ terminal png size 420,300 - s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); - eval(s) - replot; - - % larger image - - __gnuplot_set__ terminal png size 800,600 - s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); - eval(s) - replot; - - endif - -endfunction - diff --git a/wispcar/batt_test.sh b/wispcar/batt_test.sh deleted file mode 100755 index e7d472fb..00000000 --- a/wispcar/batt_test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# batt_test.sh -# David Rowe 22 June 2009 - -if [ $# -ne 2 ] -then - echo "usage ./batt_test.sh cutoff_Vcode logfile" - exit 0 -fi - -/home/stty -F /dev/tts/1 speed 4800 > /dev/null - -rm -f $2 - -# sample initial voltage - -dd if=/dev/tts/1 bs=1 count=36 1>w 2>/dev/null& -echo -n 'w' > /dev/tts/1 -sleep 2 -v=`cut -f 2 -d ' ' w` -echo $v - -# stop when voltage reaches a threshold - -while [ $v -gt $1 ] -do - - # sample voltage - - dd if=/dev/tts/1 bs=1 count=36 1>w 2>/dev/null& - echo -n 'w' > /dev/tts/1 - sleep 2 - v=`cut -f 2 -d ' ' w` - i=`cut -f 3 -d ' ' w` - echo $v $i - - echo -n `date` ' ' >> $2 - echo $v $i >> $2 - - sleep 5 - -done - - diff --git a/wispcar/caliba.m b/wispcar/caliba.m deleted file mode 100644 index 3c648b95..00000000 --- a/wispcar/caliba.m +++ /dev/null @@ -1,29 +0,0 @@ -% 0.1 ohm current sense resistor 20 June 2009 - -% Vbatt V0.1 I VbattADC IADC -d = [ -[ 8.0 0.121 1.15 36 99] -[ 8.9 0.134 1.27 41 109] -[ 9.8 0.148 1.40 44 121] -[ 11.1 0.167 1.58 50 136] -[ 12.7 0.191 1.80 58 153] -[ 13.1 0.198 1.87 59 159] -] - -figure(1) -plot(d(:,1), d(:,4)) -ylabel("ADC V"); xlabel("Vbatt (V)"); - -figure(2) -plot(d(:,3), d(:,5)) -ylabel('ADC I'); xlabel('I (A)'); - -figure(3) -plot(d(:,2), d(:,3)) -xlabel('Vsense I'); ylabel('I (A)'); - -figure(4) -plot(d(:,2), d(:,5)) -xlabel('Vsense I'); ylabel('ADC I'); -grid - diff --git a/wispcar/calibb.m b/wispcar/calibb.m deleted file mode 100644 index 3600688b..00000000 --- a/wispcar/calibb.m +++ /dev/null @@ -1,29 +0,0 @@ -% 0.1 ohm current sense resistor 20 June 2009 - -% Vbatt VbattADC IADC -d = [ -[ 9.2 118 ] -[ 10.0 129 ] -[ 11.1 142 ] -[ 12.2 156 ] -[ 13.2 169 ] -[ 14.0 179 ] -] - -d1 = [ -[ 12.12 157 ] -[ 12.00 155 ] -[ 11.86 153 ] -[ 11.68 151 ] -[ 11.47 148 ] -] - -figure(1) -plot(d(:,1), d(:,2)) -hold on -plot(d1(:,1), d1(:,2),'g') -hold off -ylabel("ADC V"); xlabel("Vbatt (V)"); -grid -axis([11 13 140 170]) - diff --git a/wispcar/countdown.c b/wispcar/countdown.c deleted file mode 100644 index a35575bf..00000000 --- a/wispcar/countdown.c +++ /dev/null @@ -1,37 +0,0 @@ -/* used to prototype algorithm for 3 digit count down timer used in wispcar.asm */ - -#include -#include - -int main() { - int x,y,z; - - x = 1; - y = 2; - z = 3; - - while(1) { - if (z == 0) { - if (y == 0) { - if (x == 0) { - exit(0); - } - else { - x--; - y = 9; - z = 9; - } - } - else { - y--; - z = 9; - } - } - else { - z--; - } - printf("%d%d%d\n",x,y,z); - } - -} - diff --git a/wispcar/documentation.txt b/wispcar/documentation.txt deleted file mode 100644 index 26e7de39..00000000 --- a/wispcar/documentation.txt +++ /dev/null @@ -1,240 +0,0 @@ -documentation.txt -Created by David Rowe May 2008 -Wispcar project - -Files ------ - -wispcar.asm........: PIC source code, compile and simulate - with Windows MPLAB 8.10 (free download) - Also explains Wispcar commands -wispcar.sch........: gEDA gschem schematic -Makefile...........: Creates PDF of schematic -documentation.txt..: This file - -Project Plan ------------- - -[ ] WP100 Documentation - [ ] Create SVN repository - [ ] Draw schematic - [ ] Write Test Report - + Discuss tests performed - + how to repeat them - + results - [ ] Software - [ ] Write Design Notes - + explain various sections of design - + discuss trade offs - -[ ] WP200 Prototype Development - [ ] Breadboard Prototype - [X] PIC with RS232 - [X] Current sensor - + high-side op-amp differential amp - [X] Power Switch - + used to switch power to AP - + controlled by watchdog and sleep function - [ ] Linear Regulator - [X] Watchdog software - [X] Sleep software - [ ] Construct Soldered Prototype - [ ] Install in Solar powered AP (Rowetel) - -[ ] WP300 Testing - [ ] Test 1: false watchdog firing - + test_watchdog.tcl Exepct script - + sends 'w' every sec, look for false WD fire - + results: after approx 40 hrs, 91,000 seconds, no false firing - - [ ] Test to determine watchdog doesn't fire by mistake - + leave running for 1 week - + stable power & router - + ensure watchdog doesn't fire by mistake - [ ] Dirty power test - + work out a way to simulate a poor power supply - + for example put power supply in series with transformer - secondary, then modulate primary with pulses - + this will give big spikes on power line - + make sure PIC never hangs - [ ] Brown out test - + vary Vbat from 30V down to 2V 10 times - + make sure PIC does not hang - -Specs: ------ - -1/ Measures Vbat and Ibat. - - Vbat between 5 and 60V - Ibat between 0 and 5A - - Measures Vbat and Ibat and reports every 1 sec to Host. - -2/ Watchdog - - Fires if no RS232 rx for TBD1 secs from host - Power is shut off for 5 seconds then reapplied - -3/ Sleep - - Send "sleepXXXX" to put power supply to sleep for XXXX seconds - -4/ Current consumption (estimated) - - Vbat = 30V I=2mA - Vbat = 5V I=2mA - - Note: we need to work out a way to get 60V operation, 78L05 - regulator can't go above 35V. - -References ----------- - -1/ Zener power supply design: - - http://www.kpsec.freeuk.com/powersup.htm - -2/ PIC10F510 datasheet from Microchip - -3/ 78L05 datasheet - -4/ IRF9540 datasheet - -Credits -------- - -Tim Ansell (Mithro) for lending me his PIC collection and programmer -Yahel Ben-David - -Notes ------ - -1/ IRF9640 FET was selected largely at random. At 19A max it may be -overkill, a cheaper FET may be more suitable. - -2/ The RS232 polarity may need to change when directly connected to a -router without level conversion, see reference docs for RS232 software -UART code in wispcar.asm. I used a MAX232 type chip for interfacing -the RS232 tx & rx to a PC's serial port for testing. - -Gotchas -------- - -1/ On the PIC12F510 we can only use 'call' to call an address in the -first 256 bytes, so put all funcs at the start of the program, main at -the end. - -2/ If the RS232 characters have occasional errors, the internal clock -oscillator may need tweaking. You can check the baud rate of the -RS232 signals using an oscilloscope, at 4800 baud the bit period -should be 208us. See PIC data sheet for information on adjusting the -internal oscillator. - -3/ The Vce(max) rating of Q2 is 35V, and Vgs(max) of Q1 +/- 20V. As -R1/R2 form a voltage divider I think this sets the maximum Vbat at 35V -for the current version, i.e. Q1 will pop first (as Vgs will hit 20V -when Vbat=40V). Need higher Vce Q2 or change circuit to limit -Vgs(max). Need to make sure sufficient Vgs to switch on Q1 at low -Vbat. Maybe two versions with different R1/R2? - -4/ Current Sensor resistor values. When building the first soldered -prototype I found that residual flux messed up the 10M R11 feedback -resistor. Scraping flux away and cleaning with solvent brought the -resistance back up again. This could be a problem with home -construction, and possibly humid environments. Perhaps we should -scale resistors down to say 100k/10k voltage dividers, 1M R11? - -5/ When building the first soldered prototype I found that the -position of the ground wires carrying high current caused the current -sensor to stop working (stuck at 0V). U2 GND and the GND of R7, R9, -R10 where at different places along the GND track carrying 0.5A. This -caused a voltage drop of about 5mV between the two GNDs. I moved the -ground connection (made the GND in GND out points close to each other -so 0.5A was only flowing thru a short section of track) and the -current sensor started working again. This suggests a carefully laid -out PCB is a good idea. - -6/ The voltage on pins 2 & 3 of U2 (+/i op-amp input) should be within -10 mV of each other with U2 unplugged. A greater difference indicates -one of the resistor values is wrong. - -TODO List ---------- - -[ ] schematic - [X] pinout of 78L05 - [X] pinout of power FET - [X] pinout of BC548 - [ ] connect + & - together on unsued op-amp sections - [X] TAPR open harwdare license -[ ] PCB ideas - [ ] extra pads for zener to drop input voltage - [ ] extra pads for general prototyping - [ ] break out extra op amp pins - + dont hard-tie them - -[X] svn repository - + with datasheet pdfs ? -[ ] wire correctly for power on reset - + test with dodgy power on curve (slow power up) -[ ] unused LM324 inputs - + check if its really OK to GND them -[X] blog post -[ ] test at 5A for 24 Hrs - + given FET on-resistance do we need a heat sink? -[X] README in SVN - + this file -[ ] Add 4th digit to sleep timer -[ ] test with WRT54 -[ ] add brown out detector to PIC reset to be double sure? - + see PIC data sheet -[ ] check what happens in overvoltage on input, how can we protect? -[ ] document test plan -[ ] get PIC part name right in symbol file -[ ] meausure the current consumption of the soldered prototype -[ ] Indicate single point grounding on schematic -[ ] Note 1% R's on schematic -[X] make sure we can't stall in RS232 input routine - + need a way to get around this..... - + malformed RS323 could cause a hang - + maybe better to just look at h/l transition or something? - + sep pic for sleep function? - + solution: integrate 1 sec delay with RS232 rx -[ ] Limitations - + need to send full command before 1 second delay? - + like send command immediately after ADC data - + need automatic reset from fragment - + like once every second - + or can it be spread over cycles? -[ ] enable PIC watchdog timer - + how can we test? -[ ] How repeatable is current sensor? - + y intercept (DC offset) - + slope - + maybe build a few a check -[ ] make sure all RS232 chars OK - + how to prog with calibrated clock? - + check baud rate - + is max232 OK at Vcc=5V? -[ ] programming procedure to preserve osccal -[X] make function to print decimal, rather than repeating all that code - + we can't as call stack is only two levels deep and we are at the limit - -[ ] automatic thrash tests (repeat each one for hours/days) - + maybe use expect - [ ] send sleep - + make sure we sleep - [ ] send 'w' - + make sure we dont WD time out - [ ] check for unlikely WD/sleep/reboot events - + especially under nasty conditions - -[ ] check how accurate the timing is - + is 1 sec delay accurate? - -[ ] work out how to run from 60V - + 78L05 pops at 35V - -[ ] Will 5V levels from PIC play nicely with 3V3 levels of router - -check data sheets! diff --git a/wispcar/gafrc b/wispcar/gafrc deleted file mode 100644 index 601dd2e3..00000000 --- a/wispcar/gafrc +++ /dev/null @@ -1,3 +0,0 @@ -(component-library "sym") -(source-library "sym") - diff --git a/wispcar/gschem-print.scm b/wispcar/gschem-print.scm deleted file mode 100644 index 57739299..00000000 --- a/wispcar/gschem-print.scm +++ /dev/null @@ -1,14 +0,0 @@ -(paper-size 11.5 8.5) -(load (string-append gedadatarc "/gschem-lightbg")) ; light background -(output-type "limits") -(output-color "enabled") - -(text-color 9 "green4" "green4" "0 0 0" 0 0 0) ; light background -(net-endpoint-color 2 "red" "red3" ".502 .094 .062" 128 24 16) ; light -(graphic-color 3 "green4" "green4" "0 0 0" 0 0 0) ; light background -(net-color 4 "blue2" "blue3" "0 0 0" 0 0 0) ; light background - -(output-text "ps") -(gschem-use-rc-values) ;You need call this after you call any -(gschem-print "dummyfilename") ;filename is specified on the command line -(gschem-exit) diff --git a/wispcar/log2octave.sh b/wispcar/log2octave.sh deleted file mode 100755 index 7067eb85..00000000 --- a/wispcar/log2octave.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# log2octave.sh -# David Rowe 23 June 2009 - -# strip out time stamp and voltage into four columns so octave batt_test.m -# can read - -cut -f 4,8 -d ' ' $1 | sed -e 's/:/ /g' > $1.oct diff --git a/wispcar/stty b/wispcar/stty deleted file mode 100755 index d350fcde..00000000 Binary files a/wispcar/stty and /dev/null differ diff --git a/wispcar/sym/LM78L05.sym b/wispcar/sym/LM78L05.sym deleted file mode 100644 index c441fd52..00000000 --- a/wispcar/sym/LM78L05.sym +++ /dev/null @@ -1,39 +0,0 @@ -v 20060906 1 -T 400 600 9 8 1 0 0 0 1 -IN -T 948 600 9 8 1 0 0 0 1 -OUT -T 900 100 9 8 1 0 0 0 1 -78L05 -B 300 300 1000 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -T 1600 1300 5 10 0 0 0 0 1 -device=78L05 -T 656 401 9 8 1 0 0 0 1 -GND -P 300 600 0 600 1 0 1 -{ -T 100 650 5 8 1 1 0 0 1 -pinnumber=1 -T 100 650 5 8 0 0 0 0 1 -pinseq=1 -} -P 800 0 800 300 1 0 0 -{ -T 700 100 5 8 1 1 0 0 1 -pinnumber=2 -T 700 100 5 8 0 0 0 0 1 -pinseq=2 -} -P 1300 600 1600 600 1 0 1 -{ -T 1430 650 5 8 1 1 0 0 1 -pinnumber=3 -T 1430 650 5 8 0 0 0 0 1 -pinseq=3 -} -T 1400 1000 8 10 1 1 0 6 1 -refdes=U? -T 1600 1100 5 10 0 0 0 0 1 -pins=3 -T 1600 900 5 10 0 0 0 0 1 -net=GND:2 diff --git a/wispcar/sym/PC12F510.sym b/wispcar/sym/PC12F510.sym deleted file mode 100644 index 7198d934..00000000 --- a/wispcar/sym/PC12F510.sym +++ /dev/null @@ -1,86 +0,0 @@ -v 20060906 1 -B 300 200 1200 1600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -P 0 1600 300 1600 1 0 0 -{ -T 200 1650 5 8 1 1 0 6 1 -pinnumber=1 -T 400 1550 5 8 1 1 0 0 1 -pinlabel=VCC -T 0 1950 5 8 0 1 0 2 1 -pintype=pwr -} -P 0 400 300 400 1 0 0 -{ -T 200 450 5 8 1 1 0 6 1 -pinnumber=4 -T 400 350 5 8 1 1 0 0 1 -pinlabel=GP3 -T 0 750 5 8 0 1 0 2 1 -pintype=in -} -P 0 800 300 800 1 0 0 -{ -T 200 850 5 8 1 1 0 6 1 -pinnumber=3 -T 400 750 5 8 1 1 0 0 1 -pinlabel=GP4 -T 0 1050 5 8 0 1 0 2 1 -pintype=tri -} -P 0 1200 300 1200 1 0 0 -{ -T 200 1250 5 8 1 1 0 6 1 -pinnumber=2 -T 400 1150 5 8 1 1 0 0 1 -pinlabel=GP5 -T 0 1550 5 8 0 1 0 2 1 -pintype=tri -} -T 2400 800 5 10 0 0 0 0 1 -device=PIC12F510 -T 1650 150 9 10 1 1 180 0 1 -PIC12F510 DIP8 -T 2400 500 5 10 0 0 0 0 1 -footprint=DIP8 -T 2400 200 5 10 0 0 0 0 1 -description=PCI Microcontroller -T -1300 500 5 10 0 0 0 0 1 -numslots=0 -P 1800 1600 1500 1600 1 0 0 -{ -T 1600 1650 5 8 1 1 0 0 1 -pinnumber=8 -T 1450 1550 5 8 1 1 0 6 1 -pinlabel=GND -T 2100 1700 5 8 0 1 0 8 1 -pintype=pwr -} -P 1800 400 1500 400 1 0 0 -{ -T 1600 450 5 8 1 1 0 0 1 -pinnumber=5 -T 1450 350 5 8 1 1 0 6 1 -pinlabel=GP2 -T 2000 450 5 8 0 1 0 8 1 -pintype=io -} -P 1800 800 1500 800 1 0 0 -{ -T 1600 850 5 8 1 1 0 0 1 -pinnumber=6 -T 1450 750 5 8 1 1 0 6 1 -pinlabel=GP1 -T 2000 950 5 8 0 1 0 8 1 -pintype=io -} -P 1800 1200 1500 1200 1 0 0 -{ -T 1600 1250 5 8 1 1 0 0 1 -pinnumber=7 -T 1450 1150 5 8 1 1 0 6 1 -pinlabel=GP0 -T 2050 1300 5 8 0 1 0 8 1 -pintype=tri -} -T 550 1950 8 10 1 1 0 6 1 -refdes=U? diff --git a/wispcar/sym/bf-5V-plus-1.sym b/wispcar/sym/bf-5V-plus-1.sym deleted file mode 100644 index 17c7f7fb..00000000 --- a/wispcar/sym/bf-5V-plus-1.sym +++ /dev/null @@ -1,15 +0,0 @@ -v 20060123 1 -P 200 0 200 200 1 0 0 -{ -T 250 50 5 6 0 1 0 0 1 -pinnumber=1 -T 250 50 5 6 0 0 0 0 1 -pinseq=1 -T 900 100 5 10 0 0 0 0 1 -pintype=pas -} -L 50 200 350 200 3 0 0 0 -1 -1 -T 75 250 9 8 1 0 0 0 1 -+5V -T 300 0 8 8 0 0 0 0 1 -net=+5V:1 diff --git a/wispcar/sym/bf-capacitor-1.sym b/wispcar/sym/bf-capacitor-1.sym deleted file mode 100644 index d5c40eca..00000000 --- a/wispcar/sym/bf-capacitor-1.sym +++ /dev/null @@ -1,31 +0,0 @@ -v 20050820 1 -P 0 200 200 200 1 0 0 -{ -T 100 250 5 8 0 1 0 0 1 -pinnumber=1 -T 100 250 5 8 0 0 0 0 1 -pinseq=1 -T 0 100 5 10 0 0 0 0 1 -pintype=pas -} -P 900 200 700 200 1 0 0 -{ -T 700 250 5 8 0 1 0 0 1 -pinnumber=2 -T 700 250 5 8 0 0 0 0 1 -pinseq=2 -T 0 100 5 10 0 0 0 0 1 -pintype=pas -} -L 400 400 400 0 3 0 0 0 -1 -1 -L 500 400 500 0 3 0 0 0 -1 -1 -L 700 200 500 200 3 0 0 0 -1 -1 -L 400 200 200 200 3 0 0 0 -1 -1 -T 300 600 5 10 0 0 0 0 1 -device=CAPACITOR -T 200 500 8 10 1 1 0 0 1 -refdes=C? -T 0 0 8 10 0 1 0 0 1 -pins=2 -T 0 0 8 10 0 1 0 0 1 -class=DISCRETE diff --git a/wispcar/sym/bf-capacitor-2.sym b/wispcar/sym/bf-capacitor-2.sym deleted file mode 100644 index 162c82b1..00000000 --- a/wispcar/sym/bf-capacitor-2.sym +++ /dev/null @@ -1,33 +0,0 @@ -v 20031231 1 -P 0 200 200 200 1 0 0 -{ -T 100 250 5 8 0 1 0 0 1 -pinnumber=1 -T 100 250 5 8 0 0 0 0 1 -pinseq=1 -T 0 100 5 10 0 0 0 0 1 -pintype=pas -} -P 900 200 700 200 1 0 0 -{ -T 700 250 5 8 0 1 0 0 1 -pinnumber=2 -T 700 250 5 8 0 0 0 0 1 -pinseq=2 -T 0 100 5 10 0 0 0 0 1 -pintype=pas -} -L 400 400 400 0 3 0 0 0 -1 -1 -L 700 200 500 200 3 0 0 0 -1 -1 -L 400 200 200 200 3 0 0 0 -1 -1 -T 400 600 5 10 0 0 0 0 1 -device=POLARIZED_CAPACITOR -A 1200 200 700 165 30 3 0 0 0 -1 -1 -L 289 400 289 300 3 0 0 0 -1 -1 -L 340 349 240 349 3 0 0 0 -1 -1 -T 200 500 8 10 1 1 0 0 1 -refdes=C? -T 0 0 8 10 0 1 0 0 1 -pins=2 -T 0 0 8 10 0 1 0 0 1 -class=DISCRETE diff --git a/wispcar/sym/bf-osc-1.sym b/wispcar/sym/bf-osc-1.sym deleted file mode 100644 index 904040af..00000000 --- a/wispcar/sym/bf-osc-1.sym +++ /dev/null @@ -1,60 +0,0 @@ -v 20050820 1 -B 300 200 1200 700 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -P 1800 400 1500 400 1 0 0 -{ -T 1600 450 5 8 1 1 0 0 1 -pinnumber=1 -T 1600 450 5 8 0 1 0 0 1 -pinseq=1 -T 1400 350 5 8 1 1 0 6 1 -pinlabel=EN -T 1600 450 5 8 0 1 0 8 1 -pintype=pas -} -P 0 700 300 700 1 0 0 -{ -T 200 750 5 8 1 1 0 6 1 -pinnumber=4 -T 200 750 5 8 0 1 0 6 1 -pinseq=4 -T 400 650 5 8 1 1 0 0 1 -pinlabel=VCC -T 200 750 5 8 0 1 0 2 1 -pintype=pwr -} -P 1800 700 1500 700 1 0 0 -{ -T 1600 750 5 8 1 1 0 0 1 -pinnumber=3 -T 1600 750 5 8 0 1 0 0 1 -pinseq=2 -T 1400 650 5 8 1 1 0 6 1 -pinlabel=OUT -T 1600 750 5 8 0 1 0 8 1 -pintype=out -} -P 0 400 300 400 1 0 0 -{ -T 200 450 5 8 1 1 0 6 1 -pinnumber=2 -T 200 450 5 8 0 1 0 6 1 -pinseq=3 -T 400 350 5 8 1 1 0 0 1 -pinlabel=GND -T 200 450 5 8 0 1 0 2 1 -pintype=pwr -} -T 1900 800 5 10 0 0 0 0 1 -device=CLOCK OSC -T 1450 150 9 10 1 1 180 0 1 -CLOCK OSC -T 1900 500 5 10 0 0 0 0 1 -footprint=bf_XTALOSC -T 1900 200 5 10 0 0 0 0 1 -description=Hi-Q QMSO-4200 Series -T 1900 0 5 10 0 0 0 0 1 -documentation=TBD -T 300 1100 8 10 1 1 0 0 1 -refdes=U? -T -1300 500 5 10 0 0 0 0 1 -numslots=0 diff --git a/wispcar/sym/bf-resistor-1.sym b/wispcar/sym/bf-resistor-1.sym deleted file mode 100644 index b2ea8c72..00000000 --- a/wispcar/sym/bf-resistor-1.sym +++ /dev/null @@ -1,34 +0,0 @@ -v 20050820 1 -L 600 200 500 0 3 0 0 0 -1 -1 -L 500 0 400 200 3 0 0 0 -1 -1 -L 400 200 300 0 3 0 0 0 -1 -1 -L 300 0 200 200 3 0 0 0 -1 -1 -T 300 400 5 10 0 0 0 0 1 -device=RESISTOR -L 600 200 700 0 3 0 0 0 -1 -1 -L 700 0 750 100 3 0 0 0 -1 -1 -P 900 100 750 100 1 0 0 -{ -T 800 150 5 8 0 1 0 0 1 -pinnumber=2 -T 800 150 5 8 0 0 0 0 1 -pinseq=2 -T 900 100 5 10 0 0 0 0 1 -pintype=pas -} -P 0 100 152 100 1 0 0 -{ -T 100 150 5 8 0 1 0 0 1 -pinnumber=1 -T 100 150 5 8 0 0 0 0 1 -pinseq=1 -T 0 100 5 10 0 0 0 0 1 -pintype=pas -} -L 201 200 150 100 3 0 0 0 -1 -1 -T 200 300 8 10 1 1 0 0 1 -refdes=R? -T 0 0 8 10 0 1 0 0 1 -pins=2 -T 0 0 8 10 0 1 0 0 1 -class=DISCRETE diff --git a/wispcar/sym/d7400.sym b/wispcar/sym/d7400.sym deleted file mode 100644 index 0e1976c5..00000000 --- a/wispcar/sym/d7400.sym +++ /dev/null @@ -1,69 +0,0 @@ -v 20060123 1 -L 300 100 300 700 3 0 0 0 -1 -1 -L 300 700 700 700 3 0 0 0 -1 -1 -T 500 800 5 10 0 0 0 0 1 -device=7400 -T 500 1000 5 10 0 0 0 0 1 -slot=1 -T 500 1200 5 10 0 0 0 0 1 -numslots=4 -T 500 1400 5 10 0 0 0 0 1 -slotdef=1:1,2,3 -T 500 1600 5 10 0 0 0 0 1 -slotdef=2:4,5,6 -T 500 1800 5 10 0 0 0 0 1 -slotdef=3:9,10,8 -T 500 2000 5 10 0 0 0 0 1 -slotdef=4:12,13,11 -L 300 100 700 100 3 0 0 0 -1 -1 -A 700 400 300 270 180 3 0 0 0 -1 -1 -V 1050 400 50 6 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -P 1100 400 1300 400 1 0 1 -{ -T 1100 450 5 8 1 1 0 0 1 -pinnumber=3 -T 1100 350 5 8 0 1 0 2 1 -pinseq=3 -T 950 400 9 8 0 1 0 6 1 -pinlabel=Y -T 950 400 5 8 0 1 0 8 1 -pintype=out -} -P 300 200 0 200 1 0 1 -{ -T 200 250 5 8 1 1 0 6 1 -pinnumber=2 -T 200 150 5 8 0 1 0 8 1 -pinseq=2 -T 350 200 9 8 0 1 0 0 1 -pinlabel=B -T 350 200 5 8 0 1 0 2 1 -pintype=in -} -P 300 600 0 600 1 0 1 -{ -T 200 650 5 8 1 1 0 6 1 -pinnumber=1 -T 200 550 5 8 0 1 0 8 1 -pinseq=1 -T 350 600 9 8 0 1 0 0 1 -pinlabel=A -T 350 600 5 8 0 1 0 2 1 -pintype=in -} -T 300 800 8 10 1 1 0 0 1 -refdes=U? -T 500 2150 5 10 0 0 0 0 1 -footprint=DTSSOP-14 -T 500 2350 5 10 0 0 0 0 1 -description=4 NAND gates with 2 inputs -T 500 2550 5 10 0 0 0 0 1 -documentation=http://www-s.ti.com/sc/ds/sn74hc00.pdf -T 0 0 8 8 0 0 0 0 1 -author=Ivan Danov -T 0 0 8 8 0 0 0 0 1 -email=idanov@gmail.com -T 0 0 8 8 0 0 0 0 1 -dist-license=GPL -T 0 0 8 8 0 0 0 0 1 -use-license=unlimited diff --git a/wispcar/sym/pmos-wispcar.sym b/wispcar/sym/pmos-wispcar.sym deleted file mode 100644 index 941dda5d..00000000 --- a/wispcar/sym/pmos-wispcar.sym +++ /dev/null @@ -1,52 +0,0 @@ -v 20060906 1 -T 600 500 5 10 0 0 0 0 1 -device=PMOS_TRANSISTOR -T 600 500 5 10 0 0 0 0 1 -numslots=0 -T 600 500 5 10 0 0 0 0 1 -description=generic P channel MOS transistor (enhancement type) -L 250 600 500 600 3 0 0 0 -1 -1 -L 250 200 500 200 3 0 0 0 -1 -1 -L 300 350 400 400 3 0 0 0 -1 -1 -L 300 450 400 400 3 0 0 0 -1 -1 -P 0 200 200 200 1 0 0 -{ -T 0 300 5 10 0 1 0 0 1 -pinnumber=G -T 0 300 9 10 1 1 0 0 1 -pinlabel=G -T 0 300 5 10 0 0 0 0 1 -pinseq=2 -T 0 300 5 10 0 0 0 0 1 -pintype=pas -} -P 500 600 500 800 1 0 1 -{ -T 300 700 5 10 0 1 0 0 1 -pinnumber=D -T 300 700 9 10 1 1 0 0 1 -pinlabel=D -T 300 700 5 10 0 0 0 0 1 -pinseq=1 -T 300 700 5 10 0 0 0 0 1 -pintype=pas -} -P 500 200 500 0 1 0 1 -{ -T 300 0 5 10 0 1 0 0 1 -pinnumber=S -T 300 0 9 10 1 1 0 0 1 -pinlabel=S -T 300 0 5 10 0 0 0 0 1 -pinseq=3 -T 300 0 5 10 0 0 0 0 1 -pintype=pas -} -T 700 600 8 10 1 1 0 0 1 -refdes=Q? -L 250 675 250 525 3 0 0 0 -1 -1 -L 250 475 250 325 3 0 0 0 -1 -1 -L 250 275 250 125 3 0 0 0 -1 -1 -L 200 600 200 200 3 0 0 0 -1 -1 -L 250 400 400 400 3 0 0 0 -1 -1 -L 400 400 400 200 3 0 0 0 -1 -1 diff --git a/wispcar/test_watchdog.tcl b/wispcar/test_watchdog.tcl deleted file mode 100755 index 41e84117..00000000 --- a/wispcar/test_watchdog.tcl +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/local/bin/expect -f -# test_watchdog.tcl - Expect script to test wispcar watch dog timer. -# -# Assumes /etc//etc/minirc.mini4800.dfl config file configured for -# 4800 baud - -set rs232 dragonballz -set send_slow {1 0.2} -set timeout -1 - -# connect to machine with RS232 port - -spawn ssh $rs232 -expect "$ " -send "killall -9 minicom\r" -expect "$ " -send "minicom mini4800.dfl\r" - -# Keep sending 'w' every second -# This shoud mean WD _never_ times out - -set fire 0 -set count 0 -while {1} { - send "w" - expect -re "(...) (...) (.) (...) (...) (...) (.) (...) (.)" - set v $expect_out(1,string) - set w $expect_out(9,string) - if {$w == "w"} { - # watchdog has fired - set fire [expr $fire+1] - send "w" - } - set count [expr $count+1] - puts "count: $count fire: $fire" -} - -close diff --git a/wispcar/wispcar.asm b/wispcar/wispcar.asm deleted file mode 100644 index a6a3bb10..00000000 --- a/wispcar/wispcar.asm +++ /dev/null @@ -1,1008 +0,0 @@ -; wispcar.asm -; David Rowe May 2008 -; -; PIC12F510 Assembler program, MPLAB V8.10 IDE used to build. -; -; ******************************************************** -; * Wifi Station Power Controller And Reporter - WiSPCaR * -; ******************************************************** -; -;--------------------------------------------------------------------- -; Copyright (C) 2008 David Rowe -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; 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. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -; USA -;--------------------------------------------------------------------- -; -; FUNCTIONS -; ========= -; -; 1/ Monitor Voltage -; 2/ Monitor Current -; 3/ Watchdog timer -; 4/ Sleep timer -; -; -; PINOUT -; ====== -; ____ ____ -; | \/ | -; Vcc --| 1 8 |-- GND -; | | -; Spare I/O --| 2 7 |-- Vsense (in) -; | | -; RS232 Tx (out) --| 3 6 |-- PowerSwitch (out) -; | | -; RS232 Rx (in) --| 4 5 |-- Isense (in) -; |__________| -; -; -; Pin | Function | PIC Name -; -----|-------------|--------- -; 2 | Spare I/O | GP5 -; 3 | RS232 Tx | GP4 -; 4 | RS232 Rx | GP3 -; 5 | Isense | AN2 -; 6 | PowerSwitch | GP1 -; 7 | Vsense | AN0 -; -; -; PIC PROGRAMMING OPTIONS -; ======================= -; -; 8MHz clock, MCLRE=I/O, INTOSC -; -; -; 4800 BAUD RS232 OUTPUT -; ====================== -; -; The following line is printed every time you send 'w' or '.', if you -; send nothing to wispcar it will remain silent. The specific chars -; minimise the chance of wispcar interfering with your boot loader. -; -; Name of script on host that parses this line -; | Vsense -; | | Isense -; | | | char received (ASCII) -; | | | | Last char received (decimal) -; | | | | | Watchdog timeout counter -; | | | | | | Watchdog fire counter -; | | | | | | | Sleep state machine state -; | | | | | | | | Sleep timeout counter -; | | | | | | | | | -; wispcar 040 031 - 032 012 000 0 000 w---reason for last restart -; b - Wispcar (re)booted -; w - watchdog timer fired -; s - we went to sleep -; - - restart flag reset -; -; COMMANDS -; ======== -; -; 1/ Send a 'w' every WD_TIMEOUT seconds to prevent Watchdog timer -; firing and cutting power. -; -; 2/ Send a '.' to report status without resetting watchdog. -; -; 3/ Send the string 'sleepxyz' to cut the power for xyz seconds, -; where x,y and z are digits in the range 0-9. If any part of the -; string is invalid it will be ignored. Wait 5 seconds and start -; again. -; -; 4/ Wispcar cannot rx and tx RS232 at the same time. Wait until after -; the current output has finished to send the next command. It is best to -; wait until just after the output line is received by the host, then -; send your command. If the command (such as sleep) gets messed up, -; just wait 5 seconds and wispcar will reset it's internal state -; machine. You can then try again. -; -; 4/ The final field is reset to a space when a 'w' is sent to -; Wispcar. This field lets the host know just _why_ it was rebooted. - - -#include - -; VARIABLES --------------------------------------------------------------------- - -TEMP equ 0x10 -SERBUF equ 0x11 ; RS232 char to transmit -count equ 0x12 ; temp reg used by "BIN2BCD" and "baud" routines -BIN equ 0x13 -huns equ 0x14 -tens equ 0x15 -ones equ 0x16 -thirty equ 0x17 ; constant set to (guess what) 30 -SERBUFI equ 0x18 ; last RS232 character we received -wd_timeout equ 0x19 ; current watchdog timer value (in secs) - ; when this hits zero we turn the power off -wd_fire equ 0x1a ; count down timer when watchdog fires (in secs) -restart_flag equ 0x1b ; tells host why we just restarted (WD or sleep) - -sleep_state equ 0x1c -sleep_timeout equ 0x1d ; current value of sleep time out (in secs) - ; measures time between rx-ed chars in - ; s-l-e-e-p-x-y-z sequence. - ; If this hits zero (like s-l- (BIG GAP)) - ; we assume sleep command - ; was invalid and we reset the input state machine - - ; three digit sleep time (up to 999 secs) - ; these count down to zero while we are sleeping - ; when count down hits 0 power is switched back on - -sleeping equ 0x1e ; asserted if we are sleeping (power off) - -; following variables are in bank1, which makes life difficult.... - -d1 equ 0x10 -d2 equ 0x11 -d3 equ 0x12 - -x equ 0x13 ; sleep time (hundreds of secs) -y equ 0x14 ; sleep time (tens of secs) -z equ 0x15 ; sleep time (secs) - -; CONSTANTS --------------------------------------------------------------------- - -WD_TIMEOUT equ d'18' ; watchdog timeout in seconds -WD_FIRE equ d'5' ; watchdog firing time in seconds - ; how long power is cut off to host - -SLEEP_TIMEOUT equ d'5' ; timeout between rx-ed chars in sleep input - ; sequence. - -; Values for restart_flag - tell host why we just cut power after we woke up - -BOOT_FLAG equ 'b' ; Wispcar just rebooted -WD_FLAG equ 'w' ; Watchdog fired -SLEEP_FLAG equ 's' ; We slept - -; START PROGRAM ---------------------------------------------------------------- - -; set up osc cal (temp code just for experimenting) -; TODO - FIX ME for general case - - movlw 16 - movwf OSCCAL - -; configure AN[1:0] as analog inputs - - movlw b'10110001' - movwf ADCON0 - -; configure GP[3] as digital input (RS232 RX) -; configure GP[4] as digital output (RS232 TX) -; configure GP[1] as digital output (PowerSwitch) - -; disble the comparitor so we can use GP[1] - - bcf CM1CON0,3 - - ; set up GPIO directions - - movlw b'00001101' - tris GPIO - -; turn on PowerSwitch - - bsf GPIO,1 - -; set up a convenient constant - - movlw h'30' - movwf thirty - -; init watchdog - - movlw WD_TIMEOUT - movwf wd_timeout - clrf wd_fire - -; init sleep - - clrf sleep_state - clrf sleeping - clrf sleep_timeout - bsf FSR,5 ; x,y,z are in bank 1 (grumble) - clrf x - clrf y - clrf z - bcf FSR,5 ; x,y,z are in bank 1 (grumble) - -; init restart_flag - - movlw BOOT_FLAG - movwf restart_flag - - goto main - -; START FUNCTIONS ------------------------------------------------------------ - -; BIN2BCD -; -; Convert 8 bit value in BIN to a 3 digit decimal value. -; -; in.......: BIN -; out......: huns, tens, ones -; Reference: http://www.piclist.com/techref/microchip/math/radix/b2a-8b3d-ab.htm -; -; Uses temp reg 'count' - -; uses ADD-3 algorithm - -BIN2BCD - movlw 8 - movwf count - clrf huns - clrf tens - clrf ones -BCDADD3 - movlw 5 - subwf huns, 0 - btfsc STATUS, C - CALL ADD3HUNS - - movlw 5 - subwf tens, 0 - btfsc STATUS, C - CALL ADD3TENS - - movlw 5 - subwf ones, 0 - btfsc STATUS, C - CALL ADD3ONES - - decf count, 1 - bcf STATUS, C - rlf BIN, 1 - rlf ones, 1 - btfsc ones,4 ; - CALL CARRYONES - rlf tens, 1 - - btfsc tens,4 ; - CALL CARRYTENS - rlf huns,1 - bcf STATUS, C - - movf count, 0 - btfss STATUS, Z - GOTO BCDADD3 - - movf huns, 0 ; add ASCII Offset - addwf thirty, 0 - movwf huns - - movf tens, 0 ; add ASCII Offset - addwf thirty, 0 - movwf tens - - movf ones, 0 ; add ASCII Offset - addwf thirty, 0 - movwf ones - - retlw 0 - -ADD3HUNS - movlw 3 - addwf huns,1 - retlw 0 - -ADD3TENS - movlw 3 - addwf tens,1 - retlw 0 - -ADD3ONES - movlw 3 - addwf ones,1 - retlw 0 - -CARRYONES - bcf ones, 4 - bsf STATUS, C - retlw 0 - -CARRYTENS - bcf tens, 4 - bsf STATUS, C - retlw 0 - -; INCH_N is from "PIC Software UART Routines" -; John Massa, Datadog Systems (C) 2005 - -; ******************************************************************** -; INCH_N -; THIS ROUTINE INPUTS RS232 DATA USING AN INVERTER, LIKE THE MAX232. -; THIS ROUTINE USES A 8-DATA BIT PER CHARACTER PROTOCOL -; GPIO,0 = RX (MARK = 1, SPACE = 0). -; TO RECIEVE A CHARACTER, CALL inch_n, THE RECEIVED CHARACTER IS PLACED -; IN THE REG 'W' AND IN THE REG 'SERBUF'. -; THE RECEIVED CHARACTER WILL ECHO IF 'RETLW 0' IS REM-ED OUT. -; VARIABLES USED: REG 'TEMP' AND REG 'SERBUF' BOTH VARIABLES ARE -; SHARED WITH THE 'outch_n' ROUTINE. -; ROUTINES CALLED: 'half_baud'AND 'baud' TO SET THE BAUD-RATE -; ******************************************************************** - -; Modified by David Rowe May 2008 to combine a 1 second delay with -; character reception. - -inch_n_delay - - ; clear previous rx char - - movlw '-' - movwf SERBUFI - - ; init delay loop for 1999996 cycles - - bsf FSR,5 ; d1, d2, d3 in Bank 1 (groan) - movlw 0x11 - movwf d1 - movlw 0x5D - movwf d2 - movlw 0x05 - movwf d3 - -wait_for_start - bcf FSR,5 ; just in case goto below fires - btfss GPIO,3 ; SKIP UNLESS WE GET A START BIT = 1 (A "MARK") - goto start_serial ; start bit - process character - - ; process delay loop while we look for start bit - - bsf FSR,5 - decfsz d1, f - goto $+2 - decfsz d2, f - goto $+2 - decfsz d3, f - goto wait_for_start - - ; delay finished - - bcf FSR,5 - retlw 0 - -start_serial - bsf GPIO,5 - bcf GPIO,5 - - movlw 8 ; START SERIAL INPUT SEQUENCE - movwf TEMP ; COLLECT 8 DATA BITS - clrf SERBUFI ; CLEAR SERIAL CHARACTER BUFFER - call half_baud ; DELAY FOR ONE HALF BAUD TIME - btfsc GPIO,3 ; FALL THRU IF START BIT STILL = 1 (A "MARK") - goto wait_for_start ; ELSE IT WAS JUST A NOISE SPIKE, KEEP LOOKING -inch_n1 - call baud ; DELAY ONE BAUD-BIT TIME ( = 1/BAUD-RATE) - bcf STATUS,0 ; CLEAR THE CARRY BIT - rrf SERBUFI,F ; ROTATE CRY -> MSB, ROTATE MSB RIGHT - btfsc GPIO,3 ; IS IT A "MARK" ? - bsf SERBUFI,7 ; ...SKIP IF YES, ELSE SET BIT TO LOGIC '1' - decfsz TEMP,F ; EIGHT COUNTS YET? - goto inch_n1 ; ...NO, GET ANOTHER BIT - call baud ; DELAY FOR THE STOP BIT - movf SERBUFI,W ; PUT THE RECEIVED CHARACTER IN REG 'W' - - ; process received character, this can be considered an "event - ; handler" for rx-chars. We expect either a 'w' to reset the - ; watchdog or a tightly defined sequence of sleep characters. - - movlw 'w' - subwf SERBUFI,0 ; is it a 'w' for watchdog reset? - btfss STATUS,Z ; skip if received char matches - goto handle_sleepin ; only process sleep input if not a 'w' - - ; handle 'w' input - - ; Note if we are sleeping or WD is firing we will keep power - ; off and receiving 'w' will have no effect. Unlikely unless - ; device sending rx chars is powered indepednantly (ie during - ; testing). - - movlw WD_TIMEOUT ; reset watchdog timer - movwf wd_timeout - - movlw '-' ; clear reboot flag - movwf restart_flag - - clrf sleep_state ; reset sleep state machine for good measure - clrf sleep_timeout ; just in case we get s-l-w-e-e-p or something - - goto wait_for_start - -handle_sleepin - call sleep_input - goto wait_for_start - -; OUTCH_N and BAUD are from "PIC Software UART Routines" -; John Massa, Datadog Systems (C) 2005 - -;********************************************************************* -; OUTCH_N -; THIS ROUTINE OUTPUTS RS232 DATA THROUGH AN INVERTER. -; THIS ROUTINE USES AN 8-DATA BIT PER CHARACTER PROTOCOL. -; TO PRINT A CHARACTER, LOAD BYTE INTO REG 'W' AND CALL outch_n. -; GPIO,1 = TX (MARK = 1, SPACE = 0) ; USE INVERTER ON THE OUTPUT -; VARIABLES USED: REG 'TEMP' AND SHARE REG 'SERBUF' WITH THE ROUTINE -; 'inch_n' -; CALLS THE ROUTINE 'baud' TO SET THE BAUD-RATE TIMING. -;********************************************************************* - -outch_n ; THIS ROUTINE USES 8 DATA BITS - movwf SERBUF ; SERBUF CONTAINS CHARACTER TO XMT - movlw 8 ; THE CHARACTER HAS 8 BITS - movwf TEMP - bcf GPIO,4 ; SET START-BIT TO A "SPACE" - call baud ; WAIT ONE BAUD TIME -outch_n1 - rrf SERBUF,F ; ROTATE THE FIRST BIT INTO CARRY - btfss STATUS,0 ; TEST THE CARRY BIT - bcf GPIO,4 ; IF BIT IS 0 SET OUTPUT PIN TO A "0" (SPACE) - btfsc STATUS,0 ; TEST THE CARRY BIT AGAIN - bsf GPIO,4 ; IF BIT IS 1 SET OUTPUT PIN TO A "1" (MARK) - call baud ; ONE BAUD-BIT DELAY - decfsz TEMP,F ; IF COUNT IS ZERO THEN XMIT A STOP BIT - goto outch_n1 ; ...ELSE XMIT NEXT BIT - rrf SERBUF,F ; ROTATE CARRY, GET THE MSB BACK INTO BIT 7 - bsf GPIO,4 ; SET PIN TO A 1 (A "MARK") FOR THE STOP BIT - call baud ; FIRST BAUD-BIT DELAY - call baud ; SECOND BAUD-BIT DELAY - retlw 0 ; RETURN WITH THE CHARACTER IN SERBUF - -; ******************************************************************** -; BAUD ROUTINE @ 4 MHz -; BAUD RATE: CONSTANT: -; 1200 Baud D'137' -; 2400 Baud D'68' -; 4800 Baud D'34' -; 9600 Baud D'16' -; 19200 Baud D'8' -; 38400 Baud and up - use 'NOP' delays -; VARIABLES USED: REG 'count' -; ROUTINES CALLED: NONE -; ******************************************************************** - -baud ; AT 2400 BAUD THE PERIOD IS 416.6 US - ; CLK = 4MHz - movlw D'68' ; 1 US (BAUD RATE CONSTANT) - movwf count ; 1 US -baud1 - decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) - goto baud1 ; 2 US - ; FALL THRU...AFTER 1+1+3x68+1 = 207 US -half_baud - movlw D'68' ; 1 US - movwf count ; 1 US -hbaud1 - decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) - goto hbaud1 ; 2 US - retlw 0 ; ...AFTER 1+1+3x68+1 = 207 US (X2=414 US) - -; http://www.piclist.com/techref/piclist/codegen/delay.htm -; Delay = 1 seconds -; Clock frequency = 8 MHz - -; Actual delay = 1 seconds = 2000000 cycles -; Error = 0 % - -delay - ;1999996 cycles - bsf FSR,5 - movlw 0x11 - movwf d1 - movlw 0x5D - movwf d2 - movlw 0x05 - movwf d3 -Delay_0 - decfsz d1, f - goto $+2 - decfsz d2, f - goto $+2 - decfsz d3, f - goto Delay_0 - - ;4 cycles - goto $+1 - goto $+1 - - bcf FSR,5 - retlw 0 - -; sleep input state machine -; -; we expect the chars s-l-e-e-p-x-y-z where xyz are digits -; if wrong char received reset -; if 5 sec timout between chars reset -; if xyz are not digits reset - -sleep_input - - ; big case statement to work out what state we are in - - movlw 0 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 's' - goto sleep_state_s - movlw 1 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'l' - goto sleep_state_l - movlw 2 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'e1' - goto sleep_state_e1 - movlw 3 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'e2' - goto sleep_state_e2 - movlw 4 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'p' - goto sleep_state_p - movlw 5 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'x' - goto sleep_state_x - movlw 6 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'y' - goto sleep_state_y - movlw 7 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'z' - goto sleep_state_z - - ; should never get here but just in case - - goto sleep_reset - - ; if we have rx-ed a 's' continue to next state -sleep_state_s - movlw 's' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 's' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'l' continue to next state -sleep_state_l - movlw 'l' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'l' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'e' continue to next state -sleep_state_e1 - movlw 'e' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'e' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'e' continue to next state -sleep_state_e2 - movlw 'e' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'e' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'p' continue to next state -sleep_state_p - movlw 'p' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'p' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_x - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if x <= 9 - bsf FSR,5 ; x is in bank 1 - movwf x - movlw d'10' - subwf x,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_y - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if y <= 9 - bsf FSR,5 ; y is in bank 1 - movwf y - movlw d'10' - subwf y,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_z - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if z <= 9 - bsf FSR,5 ; z is in bank 1 - movwf z - movlw d'10' - subwf z,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - - ; OK we made it! Lets go to SLEEP, ZZZZZzzzzzzzzzz - - clrf sleep_state - clrf sleep_timeout - movlw 1 - movwf sleeping - bcf GPIO,1 ; power switch off - - retlw 0 - - ; we bombed out in rx-ing sleep string -sleep_reset - clrf sleep_state - clrf sleep_timeout - retlw 0 - - ; increment to next state, and reset sleep timeout -sleep_cont - incf sleep_state,1 - movlw SLEEP_TIMEOUT - movwf sleep_timeout - retlw 0 - -; START MAIN LOOP ----------------------------------------------- - -main - call inch_n_delay ; RS232 RX and 1 second delay - - ; sample V, I, and print if we received a 'w' or a ' ' - - movlw 'w' - subwf SERBUFI,0 - btfsc STATUS,Z ; skip if SERBUFI != 'w' - goto sample - - movlw '.' - subwf SERBUFI,0 - btfss STATUS,Z ; skip if SERBUFI == ' ' - goto no_print - - ; sample AN[0] (voltage) -sample - movlw b'10110001' - movwf ADCON0 - bsf ADCON0,1 ; start A/D conversion -wait_adc_v - btfsc ADCON0,1 ; skip if A/D conversion finished - goto wait_adc_v - - ; print 'wispcar' to get host to call script called wispcar. - ; This script can then parse wispcar output - - movlw 'w' - call outch_n - movlw 'i' - call outch_n - movlw 's' - call outch_n - movlw 'p' - call outch_n - movlw 'c' - call outch_n - movlw 'a' - call outch_n - movlw 'r' - call outch_n - movlw ' ' - call outch_n - - ; print voltage to RS232 - - movf ADRES, 0 - movwf BIN - call BIN2BCD ; convert voltage to decimal ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print space - - movlw ' ' - call outch_n - - ; sample AN[1] (current) - - movlw b'10111001' - movwf ADCON0 - bsf ADCON0,1 ; start A/D conversion -wait_adc_i - btfsc ADCON0,1 ; skip if A/D conversion finished - goto wait_adc_i - - ; print current to RS232 - - movf ADRES, 0 - movwf BIN - call BIN2BCD ; convert current to decimal & ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print rx char - - movlw ' ' - call outch_n - movf SERBUFI, 0 - call outch_n - - ; print rx char in dec - - movlw ' ' - call outch_n - movf SERBUFI, 0 - movwf BIN - call BIN2BCD ; convert rx char to decimal & ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print wd_timeout in dec - - movlw ' ' - call outch_n - movf wd_timeout, 0 - movwf BIN - call BIN2BCD - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print wd_fire in dec - - movlw ' ' - call outch_n - movf wd_fire, 0 - movwf BIN - call BIN2BCD - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print sleep_state - - movlw ' ' - call outch_n - movlw '0' - addwf sleep_state,0 - call outch_n - - ; print sleep timer in dec - - movlw ' ' - call outch_n - movlw '0' ; print x - bsf FSR,5 - addwf x,0 - bcf FSR,5 - call outch_n - movlw '0' ; print y - bsf FSR,5 - addwf y,0 - bcf FSR,5 - call outch_n - movlw '0' ; print z - bsf FSR,5 - addwf z,0 - bcf FSR,5 - call outch_n - - ; print restart_flag - - movlw ' ' - call outch_n - movf restart_flag, 0 - call outch_n - - ; print CR-LF - - movlw '\r' - call outch_n - movlw '\n' - call outch_n - -no_print - ; has watchdog fired (wd_timeout == 0) ? - - movf wd_timeout,1 - btfsc STATUS,Z ; skip if not fired - goto watchdog_firing ; Yes? Then goto watchdog firing code - - ; are we sleeping (sleeping == 1)? - - movf sleeping,1 - btfss STATUS,Z ; skip if not sleeping - goto snooze ; Yes? Then goto sleeping code - - ; No? Then count down watchdog - - movlw 1 - subwf wd_timeout,1 - - ; Has watchdog just fired (wd_timeout == 0)? - - btfss STATUS,Z ; skip if wd_countdown is zero - goto dec_sleeptimeout ; No - continue - - ; Yes - start watchdog firing code - - bcf GPIO,1 ; PowerSwitch Off - movlw WD_FIRE - movwf wd_fire - goto main - -dec_sleeptimeout - ; has sleep state machine accepted a rx char? - - movf sleep_state,1 - btfsc STATUS,Z - goto main ; No? Then continue processing - - decfsz sleep_timeout,1 - goto main - - ; sleep state machine timeout, reset state machine - clrf sleep_state - goto main - - ; watchdog firing code - -watchdog_firing - - movlw 1 - subwf wd_fire,1 - - ; watchdog firing complete? (wd_fire == 0)? - - btfss STATUS,Z ; skip if wd_fire is zero - goto main ; No - continue - - ; Yes - reset watchdog - - bsf GPIO,1 ; PowerSwitch On - movlw WD_TIMEOUT - movwf wd_timeout - - ; Indicate WD has fired since last 'w' sent by host. A rx of - ; 'w' resets this flag. - - movlw WD_FLAG - movwf restart_flag - - goto main - - ; sleeping code - ; sleep for xyz seconds, need to count down in decimal -snooze - ; 3 digit decimal count down timer xyz, e.g. 999, 998,...001,000 - ; it's time's like these I wonder why I volunteered for this project!! :-) - ; see countdown.c for C version of this algorithm - - bsf FSR,5 - movf z,1 - btfss STATUS,Z - goto z_not_zero - movf y,1 - btfss STATUS,Z - goto y_not_zero - movf x,1 - btfss STATUS,Z - goto x_not_zero - - ; x=y=z=0 so we are finished - - bcf FSR,5 - goto sleep_finished - -z_not_zero - decf z,1 - goto continue_sleep - -y_not_zero - decf y,1 - movlw 9 - movwf z - goto continue_sleep - -x_not_zero - decf x,1 - movlw 9 - movwf y - movwf z - goto continue_sleep - - ; sleep finished - -sleep_finished - bsf GPIO,1 ; PowerSwitch On - movlw WD_TIMEOUT ; reset watchdog for good measure - movwf wd_timeout - clrf wd_fire - clrf sleep_timeout ; clear sleep timeout counter - clrf sleeping ; clear sleep flag - - ; Indicate we have just woken up from a sleep. A rx of 'w' - ; resets this. - - movlw SLEEP_FLAG - movwf restart_flag - goto main - -continue_sleep - bcf FSR,5 - goto main - -; END MAIN LOOP ----------------------------------------------- - - end - - diff --git a/wispcar/wispcar.sch b/wispcar/wispcar.sch deleted file mode 100644 index db323aba..00000000 --- a/wispcar/wispcar.sch +++ /dev/null @@ -1,328 +0,0 @@ -v 20060906 1 -C 50900 31400 1 90 0 bf-capacitor-1.sym -{ -T 50400 31900 5 10 1 1 180 0 1 -value=100nF 100V -} -C 50800 35800 1 0 0 bf-resistor-1.sym -{ -T 51000 36300 5 10 1 1 0 0 1 -refdes=R1 -T 51000 36100 5 10 1 1 0 0 1 -value=100k -} -C 43000 23300 0 0 0 title-bordered-C.sym -B 43500 23800 6800 800 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -T 43600 24000 9 10 1 0 0 0 1 -Licensed under the TAPR Open Hardware License (www.tapr.org/OHL) -T 43600 24300 9 10 1 0 0 0 1 -COPYRIGHT DAVID ROWE 2008 -T 58000 24500 9 10 1 0 0 0 1 -Wifi Station Power Controller And Reporter - WiSPCaR -T 62000 23600 9 10 1 0 0 0 1 -David Rowe -T 62000 23900 9 10 1 0 0 0 1 -0.1 -T 58500 23600 9 10 1 0 0 0 1 -1 -T 59800 23600 9 10 1 0 0 0 1 -1 -T 58000 23900 9 10 1 0 0 0 1 -wispcar.sch -C 58000 35600 1 180 1 lm324-1.sym -{ -T 57525 35650 5 8 1 1 180 6 1 -device=LM324 -T 57500 35900 5 10 1 1 180 6 1 -refdes=U2 -T 58000 35600 5 10 0 0 180 6 1 -slot=1 -} -C 56300 28300 1 0 0 lm324-1.sym -{ -T 57125 28450 5 8 0 0 0 0 1 -device=LM324 -T 57000 29100 5 10 1 1 0 0 1 -refdes=U2 -T 56300 28300 5 10 0 0 0 0 1 -slot=2 -} -C 56300 29300 1 0 0 lm324-1.sym -{ -T 57125 29450 5 8 0 0 0 0 1 -device=LM324 -T 57000 29900 5 10 1 1 0 0 1 -refdes=U2 -T 56300 29300 5 10 0 0 0 0 1 -slot=3 -} -C 56300 27200 1 0 0 lm324-1.sym -{ -T 57125 27350 5 8 0 0 0 0 1 -device=LM324 -T 57000 28100 5 10 1 1 0 0 1 -refdes=U2 -T 56300 27200 5 10 0 0 0 0 1 -slot=4 -} -C 50800 31700 1 0 0 LM78L05.sym -{ -T 52400 33000 5 10 0 0 0 0 1 -device=78L05 -T 51300 31800 5 10 1 1 0 6 1 -refdes=U3 -} -C 54800 30700 1 0 0 PC12F510.sym -{ -T 57200 31500 5 10 0 0 0 0 1 -device=PIC12F510 -T 57200 31200 5 10 0 0 0 0 1 -footprint=DIP8 -T 55350 32650 5 10 1 1 0 6 1 -refdes=U1 -} -C 52200 33800 1 0 1 npn-2.sym -{ -T 51600 34300 5 10 0 0 0 6 1 -device=NPN_TRANSISTOR -T 52400 34000 5 10 1 1 0 6 1 -refdes=Q2 -T 52100 33800 5 10 1 1 0 0 1 -value=BC548 -} -B 51400 28300 1000 1000 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -B 51500 29300 800 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -V 51900 29600 100 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -B 51500 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -B 52200 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -B 51850 27700 100 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -T 52350 30050 9 10 1 0 0 0 1 -IRF9540 -T 52900 28450 9 10 1 0 0 0 1 -BC548 -A 53200 27900 400 0 179 3 0 0 0 -1 -1 -L 52800 27900 52800 27700 3 0 0 0 -1 -1 -L 53600 27900 53600 27700 3 0 0 0 -1 -1 -L 52800 27700 53600 27700 3 0 0 0 -1 -1 -V 53000 27900 52 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -V 53200 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -V 53400 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -T 52950 27450 9 10 1 0 0 0 1 -E -T 53150 27450 9 10 1 0 0 0 1 -B -T 53350 27450 9 10 1 0 0 0 1 -C -T 51500 27450 9 10 1 0 0 0 1 -G -T 51850 27450 9 10 1 0 0 0 1 -D -T 52200 27450 9 10 1 0 0 0 1 -S -A 54350 27900 400 0 179 3 0 0 0 -1 -1 -L 53950 27900 53950 27700 3 0 0 0 -1 -1 -L 54750 27900 54750 27700 3 0 0 0 -1 -1 -L 53950 27700 54750 27700 3 0 0 0 -1 -1 -V 54150 27900 52 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -V 54350 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -V 54550 27900 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -T 54050 28450 9 10 1 0 0 0 1 -78L05 -T 53900 27450 9 10 1 0 0 0 1 -VIN -T 54150 27200 9 10 1 0 0 0 1 -GND -T 54500 27450 9 10 1 0 0 0 1 -VOUT -T 51700 28750 9 10 1 0 0 0 1 -TOP -N 50300 36700 51500 36700 4 -{ -T 50200 36800 5 10 1 1 0 0 1 -netname=VBAT_IN -} -N 50700 35900 50800 35900 4 -C 51600 35700 1 270 0 bf-resistor-1.sym -{ -T 51100 35400 5 10 1 1 0 0 1 -refdes=R2 -T 51100 35200 5 10 1 1 0 0 1 -value=100k -} -N 51700 36200 51700 35700 4 -N 50700 32300 50700 36700 4 -N 50700 32300 50800 32300 4 -C 50600 31100 1 0 0 gnd-1.sym -C 52600 31400 1 90 0 bf-capacitor-1.sym -{ -T 52900 31200 5 10 1 1 180 0 1 -value=100nF 10V -} -N 50700 31400 52400 31400 4 -N 51600 31700 51600 31400 4 -C 51600 33100 1 0 0 gnd-1.sym -C 52900 34200 1 0 0 bf-resistor-1.sym -{ -T 53100 34700 5 10 1 1 0 0 1 -refdes=R4 -T 53100 34500 5 10 1 1 0 0 1 -value=10k -} -C 52500 35700 1 270 0 bf-resistor-1.sym -{ -T 52000 35400 5 10 1 1 0 0 1 -refdes=R3 -T 52000 35200 5 10 1 1 0 0 1 -value=100k -} -C 52400 35700 1 0 0 bf-5V-plus-1.sym -C 52600 32300 1 0 0 bf-5V-plus-1.sym -N 52400 32300 54800 32300 4 -N 52200 34300 52900 34300 4 -N 52600 34800 52600 34300 4 -T 51200 37300 9 10 1 0 0 0 1 -POWER SWITCH -N 52300 36700 55000 36700 4 -T 56300 37300 9 10 1 0 0 0 1 -CURRENT SENSOR -C 55000 36600 1 0 0 bf-resistor-1.sym -{ -T 55300 36900 5 10 1 1 0 0 1 -refdes=R5 -T 55100 36400 5 10 1 1 0 0 1 -value=0.1R 5W -} -C 54400 36300 1 270 0 bf-resistor-1.sym -{ -T 54700 36000 5 10 1 1 0 0 1 -refdes=R6 -T 54700 35800 5 10 1 1 0 0 1 -value=100k 1% -} -C 54400 34900 1 270 0 bf-resistor-1.sym -{ -T 54700 34600 5 10 1 1 0 0 1 -refdes=R7 -T 54700 34400 5 10 1 1 0 0 1 -value=10k 1% -} -C 56400 36300 1 270 0 bf-resistor-1.sym -{ -T 56700 36400 5 10 1 1 0 0 1 -refdes=R8 -T 56700 36200 5 10 1 1 0 0 1 -value=100k 1% -} -C 56400 34900 1 270 0 bf-resistor-1.sym -{ -T 56700 34600 5 10 1 1 0 0 1 -refdes=R9 -T 56700 34400 5 10 1 1 0 0 1 -value=10k 1% -} -C 57500 34900 1 270 0 bf-resistor-1.sym -{ -T 57800 34100 5 10 1 1 0 0 1 -refdes=R10 -T 57800 33900 5 10 1 1 0 0 1 -value=1M 1% -} -C 58000 36000 1 0 0 bf-resistor-1.sym -{ -T 58300 36500 5 10 1 1 0 0 1 -refdes=R11 -T 58300 36300 5 10 1 1 0 0 1 -value=1M 1% -} -N 54500 36700 54500 36300 4 -N 54500 35400 54500 34900 4 -C 58600 35900 1 180 0 gnd-1.sym -N 56500 35400 56500 34900 4 -N 56500 36700 56500 36300 4 -N 55900 36700 60300 36700 4 -{ -T 59300 36800 5 10 1 1 0 0 1 -netname=VBAT_OUT -} -N 56500 35400 58000 35400 4 -N 58000 36100 56900 36100 4 -N 56900 36100 56900 35400 4 -N 58000 35000 54500 35000 4 -N 57600 35000 57600 34900 4 -C 58700 34800 1 180 0 bf-5V-plus-1.sym -C 57500 33700 1 0 0 gnd-1.sym -N 57600 34000 54500 34000 4 -N 58900 36100 59200 36100 4 -N 59200 36100 59200 35200 4 -C 56900 32200 1 90 0 gnd-1.sym -N 54800 31500 53200 31500 4 -{ -T 53200 31600 5 10 1 1 0 0 1 -netname=RS232 TX (OUT) -} -N 54800 31100 53200 31100 4 -{ -T 53200 31200 5 10 1 1 0 0 1 -netname=RS232 RX (IN) -} -N 54800 31900 53200 31900 4 -{ -T 53200 32000 5 10 1 1 0 0 1 -netname=SPARE I/O -} -N 58200 31900 56600 31900 4 -{ -T 56600 32000 5 10 1 1 0 0 1 -netname=Vsense (IN) -} -N 53800 34300 54000 34300 4 -N 54000 34300 54000 33400 4 -N 54000 33400 58500 33400 4 -N 58500 31500 58500 33400 4 -N 56600 31500 58500 31500 4 -{ -T 56600 31600 5 10 1 1 0 0 1 -netname=PowerSwitch (OUT) -} -N 56300 29900 56300 27200 4 -C 56200 26900 1 0 0 gnd-1.sym -N 59000 35200 60300 35200 4 -{ -T 59600 35300 5 10 1 1 0 0 1 -netname=Isense -} -N 60300 35200 60300 31100 4 -N 56600 31100 60300 31100 4 -{ -T 56600 31200 5 10 1 1 0 0 1 -netname=Isense (IN) -} -N 58200 33000 58200 31900 4 -C 51500 36200 1 270 1 pmos-wispcar.sym -{ -T 52000 36800 5 10 0 0 90 2 1 -device=PMOS_TRANSISTOR -T 51700 36800 5 10 1 1 180 2 1 -refdes=Q1 -T 52100 36800 5 10 1 1 0 0 1 -value=IRF9540 -} -C 51900 33300 1 0 0 bf-resistor-1.sym -{ -T 53000 33500 5 10 1 1 0 0 1 -refdes=R13 -T 53000 33300 5 10 1 1 0 0 1 -value=10k -} -N 51700 33800 51700 33400 4 -N 51700 33400 51900 33400 4 -N 52900 33000 52900 33400 4 -N 52900 33400 52800 33400 4 -N 51600 33000 58200 33000 4 -C 50700 32900 1 0 0 bf-resistor-1.sym -{ -T 50900 33400 5 10 1 1 0 0 1 -refdes=R12 -T 50900 33200 5 10 1 1 0 0 1 -value=100k -} diff --git a/wispcar/wispcar_sch.pdf b/wispcar/wispcar_sch.pdf deleted file mode 100644 index 621c0ca0..00000000 Binary files a/wispcar/wispcar_sch.pdf and /dev/null differ diff --git a/wispcar/wispcarb.asm b/wispcar/wispcarb.asm deleted file mode 100755 index aec22c43..00000000 --- a/wispcar/wispcarb.asm +++ /dev/null @@ -1,1020 +0,0 @@ -; wispcarb.asm -; David Rowe June 2009 -; -; WISPCAR modified for EV battery testing. When watchdog fires PowerSwitch -; (pin 6) stays off until the host sends a "w". This switches off current -; to the battery under test if the host side dies. This mod is just a hack -; for now. -; -; -; PIC12F510 Assembler program, MPLAB V8.10 IDE used to build. -; -; ******************************************************** -; * Wifi Station Power Controller And Reporter - WiSPCaR * -; ******************************************************** -; -;--------------------------------------------------------------------- -; Copyright (C) 2008 David Rowe -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; 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. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -; USA -;--------------------------------------------------------------------- -; -; FUNCTIONS -; ========= -; -; 1/ Monitor Voltage -; 2/ Monitor Current -; 3/ Watchdog timer -; 4/ Sleep timer -; -; -; PINOUT -; ====== -; ____ ____ -; | \/ | -; Vcc --| 1 8 |-- GND -; | | -; Spare I/O --| 2 7 |-- Vsense (in) -; | | -; RS232 Tx (out) --| 3 6 |-- PowerSwitch (out) -; | | -; RS232 Rx (in) --| 4 5 |-- Isense (in) -; |__________| -; -; -; Pin | Function | PIC Name -; -----|-------------|--------- -; 2 | Spare I/O | GP5 -; 3 | RS232 Tx | GP4 -; 4 | RS232 Rx | GP3 -; 5 | Isense | AN2 -; 6 | PowerSwitch | GP1 -; 7 | Vsense | AN0 -; -; -; PIC PROGRAMMING OPTIONS -; ======================= -; -; 8MHz clock, MCLRE=I/O, INTOSC -; -; -; 4800 BAUD RS232 OUTPUT -; ====================== -; -; The following line is printed every time you send 'w' or '.', if you -; send nothing to wispcar it will remain silent. The specific chars -; minimise the chance of wispcar interfering with your boot loader. -; -; Name of script on host that parses this line -; | Vsense -; | | Isense -; | | | char received (ASCII) -; | | | | Last char received (decimal) -; | | | | | Watchdog timeout counter -; | | | | | | Watchdog fire counter -; | | | | | | | Sleep state machine state -; | | | | | | | | Sleep timeout counter -; | | | | | | | | | -; wispcar 040 031 - 032 012 000 0 000 w---reason for last restart -; b - Wispcar (re)booted -; w - watchdog timer fired -; s - we went to sleep -; - - restart flag reset -; -; COMMANDS -; ======== -; -; 1/ Send a 'w' every WD_TIMEOUT seconds to prevent Watchdog timer -; firing and cutting power. -; -; 2/ Send a '.' to report status without resetting watchdog. -; -; 3/ Send the string 'sleepxyz' to cut the power for xyz seconds, -; where x,y and z are digits in the range 0-9. If any part of the -; string is invalid it will be ignored. Wait 5 seconds and start -; again. -; -; 4/ Wispcar cannot rx and tx RS232 at the same time. Wait until after -; the current output has finished to send the next command. It is best to -; wait until just after the output line is received by the host, then -; send your command. If the command (such as sleep) gets messed up, -; just wait 5 seconds and wispcar will reset it's internal state -; machine. You can then try again. -; -; 4/ The final field is reset to a space when a 'w' is sent to -; Wispcar. This field lets the host know just _why_ it was rebooted. - - -#include - -; VARIABLES --------------------------------------------------------------------- - -TEMP equ 0x10 -SERBUF equ 0x11 ; RS232 char to transmit -count equ 0x12 ; temp reg used by "BIN2BCD" and "baud" routines -BIN equ 0x13 -huns equ 0x14 -tens equ 0x15 -ones equ 0x16 -thirty equ 0x17 ; constant set to (guess what) 30 -SERBUFI equ 0x18 ; last RS232 character we received -wd_timeout equ 0x19 ; current watchdog timer value (in secs) - ; when this hits zero we turn the power off -wd_fire equ 0x1a ; count down timer when watchdog fires (in secs) -restart_flag equ 0x1b ; tells host why we just restarted (WD or sleep) - -sleep_state equ 0x1c -sleep_timeout equ 0x1d ; current value of sleep time out (in secs) - ; measures time between rx-ed chars in - ; s-l-e-e-p-x-y-z sequence. - ; If this hits zero (like s-l- (BIG GAP)) - ; we assume sleep command - ; was invalid and we reset the input state machine - - ; three digit sleep time (up to 999 secs) - ; these count down to zero while we are sleeping - ; when count down hits 0 power is switched back on - -sleeping equ 0x1e ; asserted if we are sleeping (power off) - -; following variables are in bank1, which makes life difficult.... - -d1 equ 0x10 -d2 equ 0x11 -d3 equ 0x12 - -x equ 0x13 ; sleep time (hundreds of secs) -y equ 0x14 ; sleep time (tens of secs) -z equ 0x15 ; sleep time (secs) - -; CONSTANTS --------------------------------------------------------------------- - -WD_TIMEOUT equ d'18' ; watchdog timeout in seconds -WD_FIRE equ d'5' ; watchdog firing time in seconds - ; how long power is cut off to host - -SLEEP_TIMEOUT equ d'5' ; timeout between rx-ed chars in sleep input - ; sequence. - -; Values for restart_flag - tell host why we just cut power after we woke up - -BOOT_FLAG equ 'b' ; Wispcar just rebooted -WD_FLAG equ 'w' ; Watchdog fired -SLEEP_FLAG equ 's' ; We slept - -; START PROGRAM ---------------------------------------------------------------- - -; set up osc cal (temp code just for experimenting) -; TODO - FIX ME for general case - - movlw 16 - movwf OSCCAL - -; configure AN[1:0] as analog inputs - - movlw b'10110001' - movwf ADCON0 - -; configure GP[3] as digital input (RS232 RX) -; configure GP[4] as digital output (RS232 TX) -; configure GP[1] as digital output (PowerSwitch) - -; disble the comparitor so we can use GP[1] - - bcf CM1CON0,3 - - ; set up GPIO directions - - movlw b'00001101' - tris GPIO - -; turn on PowerSwitch - - bsf GPIO,1 - -; set up a convenient constant - - movlw h'30' - movwf thirty - -; init watchdog - - movlw WD_TIMEOUT - movwf wd_timeout - clrf wd_fire - -; init sleep - - clrf sleep_state - clrf sleeping - clrf sleep_timeout - bsf FSR,5 ; x,y,z are in bank 1 (grumble) - clrf x - clrf y - clrf z - bcf FSR,5 ; x,y,z are in bank 1 (grumble) - -; init restart_flag - - movlw BOOT_FLAG - movwf restart_flag - - goto main - -; START FUNCTIONS ------------------------------------------------------------ - -; BIN2BCD -; -; Convert 8 bit value in BIN to a 3 digit decimal value. -; -; in.......: BIN -; out......: huns, tens, ones -; Reference: http://www.piclist.com/techref/microchip/math/radix/b2a-8b3d-ab.htm -; -; Uses temp reg 'count' - -; uses ADD-3 algorithm - -BIN2BCD - movlw 8 - movwf count - clrf huns - clrf tens - clrf ones -BCDADD3 - movlw 5 - subwf huns, 0 - btfsc STATUS, C - CALL ADD3HUNS - - movlw 5 - subwf tens, 0 - btfsc STATUS, C - CALL ADD3TENS - - movlw 5 - subwf ones, 0 - btfsc STATUS, C - CALL ADD3ONES - - decf count, 1 - bcf STATUS, C - rlf BIN, 1 - rlf ones, 1 - btfsc ones,4 ; - CALL CARRYONES - rlf tens, 1 - - btfsc tens,4 ; - CALL CARRYTENS - rlf huns,1 - bcf STATUS, C - - movf count, 0 - btfss STATUS, Z - GOTO BCDADD3 - - movf huns, 0 ; add ASCII Offset - addwf thirty, 0 - movwf huns - - movf tens, 0 ; add ASCII Offset - addwf thirty, 0 - movwf tens - - movf ones, 0 ; add ASCII Offset - addwf thirty, 0 - movwf ones - - retlw 0 - -ADD3HUNS - movlw 3 - addwf huns,1 - retlw 0 - -ADD3TENS - movlw 3 - addwf tens,1 - retlw 0 - -ADD3ONES - movlw 3 - addwf ones,1 - retlw 0 - -CARRYONES - bcf ones, 4 - bsf STATUS, C - retlw 0 - -CARRYTENS - bcf tens, 4 - bsf STATUS, C - retlw 0 - -; INCH_N is from "PIC Software UART Routines" -; John Massa, Datadog Systems (C) 2005 - -; ******************************************************************** -; INCH_N -; THIS ROUTINE INPUTS RS232 DATA USING AN INVERTER, LIKE THE MAX232. -; THIS ROUTINE USES A 8-DATA BIT PER CHARACTER PROTOCOL -; GPIO,0 = RX (MARK = 1, SPACE = 0). -; TO RECIEVE A CHARACTER, CALL inch_n, THE RECEIVED CHARACTER IS PLACED -; IN THE REG 'W' AND IN THE REG 'SERBUF'. -; THE RECEIVED CHARACTER WILL ECHO IF 'RETLW 0' IS REM-ED OUT. -; VARIABLES USED: REG 'TEMP' AND REG 'SERBUF' BOTH VARIABLES ARE -; SHARED WITH THE 'outch_n' ROUTINE. -; ROUTINES CALLED: 'half_baud'AND 'baud' TO SET THE BAUD-RATE -; ******************************************************************** - -; Modified by David Rowe May 2008 to combine a 1 second delay with -; character reception. - -inch_n_delay - - ; clear previous rx char - - movlw '-' - movwf SERBUFI - - ; init delay loop for 1999996 cycles - - bsf FSR,5 ; d1, d2, d3 in Bank 1 (groan) - movlw 0x11 - movwf d1 - movlw 0x5D - movwf d2 - movlw 0x05 - movwf d3 - -wait_for_start - bcf FSR,5 ; just in case goto below fires - btfss GPIO,3 ; SKIP UNLESS WE GET A START BIT = 1 (A "MARK") - goto start_serial ; start bit - process character - - ; process delay loop while we look for start bit - - bsf FSR,5 - decfsz d1, f - goto $+2 - decfsz d2, f - goto $+2 - decfsz d3, f - goto wait_for_start - - ; delay finished - - bcf FSR,5 - retlw 0 - -start_serial - bsf GPIO,5 - bcf GPIO,5 - - movlw 8 ; START SERIAL INPUT SEQUENCE - movwf TEMP ; COLLECT 8 DATA BITS - clrf SERBUFI ; CLEAR SERIAL CHARACTER BUFFER - call half_baud ; DELAY FOR ONE HALF BAUD TIME - btfsc GPIO,3 ; FALL THRU IF START BIT STILL = 1 (A "MARK") - goto wait_for_start ; ELSE IT WAS JUST A NOISE SPIKE, KEEP LOOKING -inch_n1 - call baud ; DELAY ONE BAUD-BIT TIME ( = 1/BAUD-RATE) - bcf STATUS,0 ; CLEAR THE CARRY BIT - rrf SERBUFI,F ; ROTATE CRY -> MSB, ROTATE MSB RIGHT - btfsc GPIO,3 ; IS IT A "MARK" ? - bsf SERBUFI,7 ; ...SKIP IF YES, ELSE SET BIT TO LOGIC '1' - decfsz TEMP,F ; EIGHT COUNTS YET? - goto inch_n1 ; ...NO, GET ANOTHER BIT - call baud ; DELAY FOR THE STOP BIT - movf SERBUFI,W ; PUT THE RECEIVED CHARACTER IN REG 'W' - - ; process received character, this can be considered an "event - ; handler" for rx-chars. We expect either a 'w' to reset the - ; watchdog or a tightly defined sequence of sleep characters. - - movlw 'w' - subwf SERBUFI,0 ; is it a 'w' for watchdog reset? - btfss STATUS,Z ; skip if received char matches - goto handle_sleepin ; only process sleep input if not a 'w' - - ; handle 'w' input - - ; Note if we are sleeping or WD is firing we will keep power - ; off and receiving 'w' will have no effect. Unlikely unless - ; device sending rx chars is powered indepednantly (ie during - ; testing). - - movlw WD_TIMEOUT ; reset watchdog timer - movwf wd_timeout - - ; DR June 2009 - mods - bsf GPIO,1 - - movlw '-' ; clear reboot flag - movwf restart_flag - - clrf sleep_state ; reset sleep state machine for good measure - clrf sleep_timeout ; just in case we get s-l-w-e-e-p or something - - goto wait_for_start - -handle_sleepin - call sleep_input - goto wait_for_start - -; OUTCH_N and BAUD are from "PIC Software UART Routines" -; John Massa, Datadog Systems (C) 2005 - -;********************************************************************* -; OUTCH_N -; THIS ROUTINE OUTPUTS RS232 DATA THROUGH AN INVERTER. -; THIS ROUTINE USES AN 8-DATA BIT PER CHARACTER PROTOCOL. -; TO PRINT A CHARACTER, LOAD BYTE INTO REG 'W' AND CALL outch_n. -; GPIO,1 = TX (MARK = 1, SPACE = 0) ; USE INVERTER ON THE OUTPUT -; VARIABLES USED: REG 'TEMP' AND SHARE REG 'SERBUF' WITH THE ROUTINE -; 'inch_n' -; CALLS THE ROUTINE 'baud' TO SET THE BAUD-RATE TIMING. -;********************************************************************* - -outch_n ; THIS ROUTINE USES 8 DATA BITS - movwf SERBUF ; SERBUF CONTAINS CHARACTER TO XMT - movlw 8 ; THE CHARACTER HAS 8 BITS - movwf TEMP - bcf GPIO,4 ; SET START-BIT TO A "SPACE" - call baud ; WAIT ONE BAUD TIME -outch_n1 - rrf SERBUF,F ; ROTATE THE FIRST BIT INTO CARRY - btfss STATUS,0 ; TEST THE CARRY BIT - bcf GPIO,4 ; IF BIT IS 0 SET OUTPUT PIN TO A "0" (SPACE) - btfsc STATUS,0 ; TEST THE CARRY BIT AGAIN - bsf GPIO,4 ; IF BIT IS 1 SET OUTPUT PIN TO A "1" (MARK) - call baud ; ONE BAUD-BIT DELAY - decfsz TEMP,F ; IF COUNT IS ZERO THEN XMIT A STOP BIT - goto outch_n1 ; ...ELSE XMIT NEXT BIT - rrf SERBUF,F ; ROTATE CARRY, GET THE MSB BACK INTO BIT 7 - bsf GPIO,4 ; SET PIN TO A 1 (A "MARK") FOR THE STOP BIT - call baud ; FIRST BAUD-BIT DELAY - call baud ; SECOND BAUD-BIT DELAY - retlw 0 ; RETURN WITH THE CHARACTER IN SERBUF - -; ******************************************************************** -; BAUD ROUTINE @ 4 MHz -; BAUD RATE: CONSTANT: -; 1200 Baud D'137' -; 2400 Baud D'68' -; 4800 Baud D'34' -; 9600 Baud D'16' -; 19200 Baud D'8' -; 38400 Baud and up - use 'NOP' delays -; VARIABLES USED: REG 'count' -; ROUTINES CALLED: NONE -; ******************************************************************** - -baud ; AT 2400 BAUD THE PERIOD IS 416.6 US - ; CLK = 4MHz - movlw D'68' ; 1 US (BAUD RATE CONSTANT) - movwf count ; 1 US -baud1 - decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) - goto baud1 ; 2 US - ; FALL THRU...AFTER 1+1+3x68+1 = 207 US -half_baud - movlw D'68' ; 1 US - movwf count ; 1 US -hbaud1 - decfsz count,F ; 1 US (+ 1 US MORE IF SKIP) - goto hbaud1 ; 2 US - retlw 0 ; ...AFTER 1+1+3x68+1 = 207 US (X2=414 US) - -; http://www.piclist.com/techref/piclist/codegen/delay.htm -; Delay = 1 seconds -; Clock frequency = 8 MHz - -; Actual delay = 1 seconds = 2000000 cycles -; Error = 0 % - -delay - ;1999996 cycles - bsf FSR,5 - movlw 0x11 - movwf d1 - movlw 0x5D - movwf d2 - movlw 0x05 - movwf d3 -Delay_0 - decfsz d1, f - goto $+2 - decfsz d2, f - goto $+2 - decfsz d3, f - goto Delay_0 - - ;4 cycles - goto $+1 - goto $+1 - - bcf FSR,5 - retlw 0 - -; sleep input state machine -; -; we expect the chars s-l-e-e-p-x-y-z where xyz are digits -; if wrong char received reset -; if 5 sec timout between chars reset -; if xyz are not digits reset - -sleep_input - - ; big case statement to work out what state we are in - - movlw 0 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 's' - goto sleep_state_s - movlw 1 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'l' - goto sleep_state_l - movlw 2 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'e1' - goto sleep_state_e1 - movlw 3 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'e2' - goto sleep_state_e2 - movlw 4 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'p' - goto sleep_state_p - movlw 5 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'x' - goto sleep_state_x - movlw 6 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'y' - goto sleep_state_y - movlw 7 - subwf sleep_state,0 - btfsc STATUS,Z ; Z set if in state 'z' - goto sleep_state_z - - ; should never get here but just in case - - goto sleep_reset - - ; if we have rx-ed a 's' continue to next state -sleep_state_s - movlw 's' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 's' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'l' continue to next state -sleep_state_l - movlw 'l' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'l' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'e' continue to next state -sleep_state_e1 - movlw 'e' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'e' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'e' continue to next state -sleep_state_e2 - movlw 'e' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'e' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a 'p' continue to next state -sleep_state_p - movlw 'p' - subwf SERBUFI,0 - btfss STATUS,Z ; Z set if we received a 'p' - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_x - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if x <= 9 - bsf FSR,5 ; x is in bank 1 - movwf x - movlw d'10' - subwf x,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_y - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if y <= 9 - bsf FSR,5 ; y is in bank 1 - movwf y - movlw d'10' - subwf y,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - goto sleep_cont - - ; if we have rx-ed a digit 0-9 continue to next state -sleep_state_z - - ; check if >= '0' - movlw '0' - subwf SERBUFI,0 - btfss STATUS,C ; C set if valid - goto sleep_reset - - ; check if z <= 9 - bsf FSR,5 ; z is in bank 1 - movwf z - movlw d'10' - subwf z,0 - bcf FSR,5 - btfsc STATUS,C ; C reset if valid - goto sleep_reset - - ; OK we made it! Lets go to SLEEP, ZZZZZzzzzzzzzzz - - clrf sleep_state - clrf sleep_timeout - movlw 1 - movwf sleeping - bcf GPIO,1 ; power switch off - - retlw 0 - - ; we bombed out in rx-ing sleep string -sleep_reset - clrf sleep_state - clrf sleep_timeout - retlw 0 - - ; increment to next state, and reset sleep timeout -sleep_cont - incf sleep_state,1 - movlw SLEEP_TIMEOUT - movwf sleep_timeout - retlw 0 - -; START MAIN LOOP ----------------------------------------------- - -main - call inch_n_delay ; RS232 RX and 1 second delay - - ; sample V, I, and print if we received a 'w' or a ' ' - - movlw 'w' - subwf SERBUFI,0 - btfsc STATUS,Z ; skip if SERBUFI != 'w' - goto sample - - movlw '.' - subwf SERBUFI,0 - btfss STATUS,Z ; skip if SERBUFI == ' ' - goto no_print - - ; sample AN[0] (voltage) -sample - movlw b'10110001' - movwf ADCON0 - bsf ADCON0,1 ; start A/D conversion -wait_adc_v - btfsc ADCON0,1 ; skip if A/D conversion finished - goto wait_adc_v - - ; print 'wispcar' to get host to call script called wispcar. - ; This script can then parse wispcar output - - movlw 'w' - call outch_n - movlw 'i' - call outch_n - movlw 's' - call outch_n - movlw 'p' - call outch_n - movlw 'c' - call outch_n - movlw 'a' - call outch_n - movlw 'r' - call outch_n - movlw ' ' - call outch_n - - ; print voltage to RS232 - - movf ADRES, 0 - movwf BIN - call BIN2BCD ; convert voltage to decimal ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print space - - movlw ' ' - call outch_n - - ; sample AN[1] (current) - - movlw b'10111001' - movwf ADCON0 - bsf ADCON0,1 ; start A/D conversion -wait_adc_i - btfsc ADCON0,1 ; skip if A/D conversion finished - goto wait_adc_i - - ; print current to RS232 - - movf ADRES, 0 - movwf BIN - call BIN2BCD ; convert current to decimal & ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print rx char - - movlw ' ' - call outch_n - movf SERBUFI, 0 - call outch_n - - ; print rx char in dec - - movlw ' ' - call outch_n - movf SERBUFI, 0 - movwf BIN - call BIN2BCD ; convert rx char to decimal & ASCII - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print wd_timeout in dec - - movlw ' ' - call outch_n - movf wd_timeout, 0 - movwf BIN - call BIN2BCD - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print wd_fire in dec - - movlw ' ' - call outch_n - movf wd_fire, 0 - movwf BIN - call BIN2BCD - - movf huns, 0 - call outch_n - movf tens, 0 - call outch_n - movf ones, 0 - call outch_n - - ; print sleep_state - - movlw ' ' - call outch_n - movlw '0' - addwf sleep_state,0 - call outch_n - - ; print sleep timer in dec - - movlw ' ' - call outch_n - movlw '0' ; print x - bsf FSR,5 - addwf x,0 - bcf FSR,5 - call outch_n - movlw '0' ; print y - bsf FSR,5 - addwf y,0 - bcf FSR,5 - call outch_n - movlw '0' ; print z - bsf FSR,5 - addwf z,0 - bcf FSR,5 - call outch_n - - ; print restart_flag - - movlw ' ' - call outch_n - movf restart_flag, 0 - call outch_n - - ; print CR-LF - - movlw '\r' - call outch_n - movlw '\n' - call outch_n - -no_print - ; has watchdog fired (wd_timeout == 0) ? - - movf wd_timeout,1 - btfsc STATUS,Z ; skip if not fired - goto watchdog_firing ; Yes? Then goto watchdog firing code - - ; are we sleeping (sleeping == 1)? - - movf sleeping,1 - btfss STATUS,Z ; skip if not sleeping - goto snooze ; Yes? Then goto sleeping code - - ; No? Then count down watchdog - - movlw 1 - subwf wd_timeout,1 - - ; Has watchdog just fired (wd_timeout == 0)? - - btfss STATUS,Z ; skip if wd_countdown is zero - goto dec_sleeptimeout ; No - continue - - ; Yes - start watchdog firing code - - bcf GPIO,1 ; PowerSwitch Off - movlw WD_FIRE - movwf wd_fire - goto main - -dec_sleeptimeout - ; has sleep state machine accepted a rx char? - - movf sleep_state,1 - btfsc STATUS,Z - goto main ; No? Then continue processing - - decfsz sleep_timeout,1 - goto main - - ; sleep state machine timeout, reset state machine - clrf sleep_state - goto main - - ; watchdog firing code - -watchdog_firing - - movlw 1 - - ; DR June 2009 - make watchdog fire forerver, cutting power - ; from battery indefinately until host returns - subwf wd_fire,0 - - ; watchdog firing complete? (wd_fire == 0)? - - btfss STATUS,Z ; skip if wd_fire is zero - goto main ; No - continue - - ; Yes - reset watchdog - - bsf GPIO,1 ; PowerSwitch On - movlw WD_TIMEOUT - movwf wd_timeout - - ; Indicate WD has fired since last 'w' sent by host. A rx of - ; 'w' resets this flag. - - movlw WD_FLAG - movwf restart_flag - - goto main - - ; sleeping code - ; sleep for xyz seconds, need to count down in decimal -snooze - ; 3 digit decimal count down timer xyz, e.g. 999, 998,...001,000 - ; it's time's like these I wonder why I volunteered for this project!! :-) - ; see countdown.c for C version of this algorithm - - bsf FSR,5 - movf z,1 - btfss STATUS,Z - goto z_not_zero - movf y,1 - btfss STATUS,Z - goto y_not_zero - movf x,1 - btfss STATUS,Z - goto x_not_zero - - ; x=y=z=0 so we are finished - - bcf FSR,5 - goto sleep_finished - -z_not_zero - decf z,1 - goto continue_sleep - -y_not_zero - decf y,1 - movlw 9 - movwf z - goto continue_sleep - -x_not_zero - decf x,1 - movlw 9 - movwf y - movwf z - goto continue_sleep - - ; sleep finished - -sleep_finished - bsf GPIO,1 ; PowerSwitch On - movlw WD_TIMEOUT ; reset watchdog for good measure - movwf wd_timeout - clrf wd_fire - clrf sleep_timeout ; clear sleep timeout counter - clrf sleeping ; clear sleep flag - - ; Indicate we have just woken up from a sleep. A rx of 'w' - ; resets this. - - movlw SLEEP_FLAG - movwf restart_flag - goto main - -continue_sleep - bcf FSR,5 - goto main - -; END MAIN LOOP ----------------------------------------------- - - end - - diff --git a/wispcar/wispcarb_sch.pdf b/wispcar/wispcarb_sch.pdf deleted file mode 100644 index 825386f8..00000000 Binary files a/wispcar/wispcarb_sch.pdf and /dev/null differ